Subject: Re: set-uid scripts
To: David Forbes <david@flossy.u-net.com>
From: Andrew Brown <atatat@atatdot.net>
List: current-users
Date: 11/01/1999 16:31:19
>> you also need to close (or redirect) stderr.  cron (presumably) still
>> has a pipe to that and will wait for it to end.
>
>I'm afraid I must be doing something even more silly than this, because
>even with:
>
>@reboot			<path-to-script>/<my-script>  2>&1  >/dev/null

because of the way that sh parses the command line, so stderr would
get redirected to the same place as stdout (cron's pipe) and then
stdout would get redirected to /dev/null.  so change that to 

   @reboot <path-to-script>/<my-script> >/dev/null 2>&1

and stdout will get sent to /dev/null, and then stderr will get sent
to the same place.

>the second instance of cron remains.  FWIW, the script is a perl script
>and does:
>
>if (fork() != 0) { exit(0); }
>
>before doing anything, which has the desired effect at the command prompt
>of causing it to disappear off into the background.  

well...your shell will lose track of it, but it'll still be "attached"
to the current tty.  the tty ioctl TIOCNOTTY will take care of this
for you, however, it might be tricky from perl.

check the man page and source for for daemon(3).

-- 
|-----< "CODE WARRIOR" >-----|
codewarrior@daemon.org             * "ah!  i see you have the internet
twofsonet@graffiti.com (Andrew Brown)                that goes *ping*!"
andrew@crossbar.com       * "information is power -- share the wealth."