Script doesn't keep running from other script

Alan Dayley adayley at gmail.com
Tue May 13 12:41:59 PDT 2008


On Tue, May 13, 2008 at 6:49 AM, Denys Vlasenko
<vda.linux at googlemail.com> wrote:
> Hi Alan,
>
>  Do not remove CC to the mailing list.
>  Having it on mailing lists increases chances of you getting help.

Thanks for the reminder.  I did not pay attention to the CC setting.
I certainly do want this thread in the email list.

>  On Sunday 11 May 2008 07:32, Alan Dayley wrote:
> > >  Please show the startup script.
>  >
>  > ----------- [/mnt/FlashMemory/startup start]---------------
>  > # load clock/calendar driver
>  > insmod /lib/modules/clockcal.o
>  > # Setup networking
>  > ifconfig eth0 10.42.24.10 netmask 255.255.255.0
>  > route add default gw 10.42.24.191 eth0
>  > # Set known password file
>  > cp /mnt/FlashMemory/passwd /etc/passwd
>  > # Trigger the USB storage mount/unmount daemon
>
> > /bin/sh /mnt/FlashMemory/usbmountd &
>
> > # Welcome with a date
>  > echo Welcome! Thank you for using Linux.
>  > date
>  > ----------- [/mnt/FlashMemory/startup end]---------------
>
>  A thought: seems that /mnt/FlashMemory/startup starts /mnt/FlashMemory/usbmountd
>  in background *and exits soon afterwards*.
>
>  Starting process in background via "foo &" does not fully detach it from
>  parent process group, session and controlling terminal.
>  And when parent process exits and terminal is destroyed
>  (e.g. if it is a telnet session etc), children may get killed.
>
>  To guard against these surprises, take case to fully detach:
>  instead of "... &", use:
>
>  setsid ... >/dev/null 2>&1 </dev/null  &
>
>  You may do >/a/log/file instead if you want to save output for debugging purposes.

Excellent point!  I will try this ASAP this evening.  Let me confirm
since this syntax is not that familiar to me.  Instead of:

/bin/sh /mnt/FlashMemory/usbmountd &

I should use the command line:

setsid /bin/sh /mnt/FlashMemory/usbmountd >/dev/null 2>&1 </dev/null &

Correct?  Does it need some punctuation?

Alan


More information about the busybox mailing list