On Sunday 12 April 2009 17:57:34 Jamie Lokier wrote: > Mike Frysinger wrote: > > On Monday 06 April 2009 06:12:06 Mike Frysinger wrote: > > > On Saturday 28 February 2009 14:16:30 Jamie Lokier wrote: > > > > Mike Frysinger wrote: > > > > > (like daemonizing code) > > > > > > > > It is possible to daemonize on uClinux without exec'ing a new > > > > process, using clone() instead of vfork(). I have a version of the > > > > daemon() function which does that, which I posted to the Busybox bug > > > > tracker years ago; I should really submit it to uClibc. > > > > > > so we're working on converting the old mantis db to bugzilla, but it's > > > not complete (attachments are missing). i tried searching for this but > > > wasnt able to find it. could you give it a spin ? > > > http://bugstest.busybox.net/ > > > > > > otherwise i dont suppose you could dig up your old patch ? having > > > daemon() support in uClibc would be pretty nice to have under no-mmu > > > ... i read through the clone() man page for a while, but i couldnt seem > > > to trick my head into figuring out how to emulate proper behavior where > > > the parent and grand parent die but the child keeps running, and the > > > child is able to return to the calling function with the stack intact. > > > > nm, what i was missing was that the function argument is evaluated > > by userspace, not the kernel. so it's pretty easy to use clone to > > (1) have the parent immediately call _exit and (2) have the child > > return untouched, and (3) do it in parallel. i'll add this to > > uClibc once i test with a real app other than my simple code that > > just calls daemon() after checking pgrp/sid. > > It's easy but you need an asm wrapper for each architecture, as the > parent must not touch the stack before calling _exit.
i'm aware of this which is why i used INTERNAL_SYSCALL() rather than calling the C library functions. those expand into the appropriate assembly for making a system call. > You also have to block signals in the parent otherwise the parent may > clobber the stack handling a signal before _exit. i missed this, so i'll have to add it. should be easy though. -mike
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ uClinux-dev mailing list uClinux-dev@uclinux.org http://mailman.uclinux.org/mailman/listinfo/uclinux-dev This message was resent by uclinux-dev@uclinux.org To unsubscribe see: http://mailman.uclinux.org/mailman/options/uclinux-dev