Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 16 Jul 2014 10:55:52 +0100
From:      krad <kraduk@gmail.com>
To:        Karl Pielorz <kpielorz_lst@tdx.co.uk>
Cc:        FreeBSD Questions <freebsd-questions@freebsd.org>
Subject:   Re: sh 'sleep' and trap?
Message-ID:  <CALfReyf4E-OCX0x3SBwRQRKHcmt8vBXBKr5ivPqv1Bbe9dkCXQ@mail.gmail.com>
In-Reply-To: <917611ACD1C0644B793C5B81@Mail-PC.tdx.co.uk>
References:  <917611ACD1C0644B793C5B81@Mail-PC.tdx.co.uk>

next in thread | previous in thread | raw e-mail | index | archive | help
send a kill to the script and then to the sleep process itself?


On 16 July 2014 10:31, Karl Pielorz <kpielorz_lst@tdx.co.uk> wrote:

>
> Hi All,
>
> I have a script, similar to this:
>
> "
> #!/bin/sh
>
> echo $$ >/var/run/mypid.pid
> trap "rm /var/run/mypid.pid; exit 0" EXIT
>
> while [ 1 ]
> do
>
>    do_stuff
>    sleep 60
>
> done
> "
>
> This works - but an attempt to 'kill' it, e.g.
>
> kill `head -1 /var/run/mypid.pid`
>
> Takes up to 60 seconds, before 'sleep' completes, control returns back to
> the shell - which see's the signal, and quits.
>
> Is there a better way of doing this? - i.e. some way the shell can 'pass
> time' but still receive signals in a timely manner?
>
> The only work around I could come up with was to change the 'sleep 60'
> into a loop that does 60 * 1 second sleeps, not ideal though :(
>
> Cheers,
>
> -Karl
> _______________________________________________
> freebsd-questions@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-
> unsubscribe@freebsd.org"
>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CALfReyf4E-OCX0x3SBwRQRKHcmt8vBXBKr5ivPqv1Bbe9dkCXQ>