[PATCH] start-stop-daemon: close extra fds on --background

Andreas Wetzel andreas.wetzel at bridgeco.net
Tue Jul 1 02:32:26 PDT 2008


Roy Marples wrote:
> On Tuesday 01 July 2008 09:27:22 Andreas Wetzel wrote:
>> hi again,
>>
>> in start-stop-daemon, if --background is given, i think we should
>> completely detach the called process, including closing all extra
>> file-descriptors.
>> for non-mmu, this seems to be the case. but if BB_MMU is set, we do not
>> set the DAEMON_CLOSE_EXTRA_FDS flag when calling bb_daemonize.
>>
>> the attached patch sets this flag, therefore makes the behaviour
>> consistent for the mmu and non-mmu case (diffed against the
>> busybox_1_9_stable branch).
> 
> I would expect this to work
> 
> echo "password" | 
> start-stop-daemon --start --exec /usr/sbin/pppd --background -- plugins 
> passwdfd 0
> 
> Your patch would break that yes?

Your start-stop-daemon command gets its input from stdin.
Setting the DAEMON_CLOSE_EXTRA_FDS flag closes all file descriptors 
except stdin, stdout and stderr. So it should not change the behaviour 
of your commandline.

But - after reviewing the bb_daemonize_or_rexec code - I think, your 
command will not work at all. Independent of the DAEMON_CLOSE_EXTRA_FDS 
flag, bb_daemonize_or_rexec currently does connect the called processes 
stdin, -out and -err to /dev/null. So if I'm right, it's not possible to 
pipe "password" to a start-stop-daemon call if --background is given. 
With or without the patch. Correct me if I'm wrong...

cheers,
andi


More information about the busybox mailing list