[PATCH] dropbear-051: uClinux vfork

Rob Landley rob at landley.net
Thu Oct 23 10:01:58 WST 2008


On Tuesday 21 October 2008 00:01:56 Mike Frysinger wrote:
> -	if ((pid = fork()) == -1)
> +#ifdef __uClinux__
> +	pid = vfork();
> +#else
> +	pid = fork();
> +#endif /* __uClinux__ */
> +	if (pid == -1)
>  		fatal("do_local_cmd: fork: %s", strerror(errno));

If it's ever safe to call vfork() from a given place, then it should always be 
safe to call it from that place, so the #ifdef isn't really necessary.

Although vfork() has more restrictive semantics than fork() does, it's not 
really less efficient than doing a fork().  Just less flexible.  A system 
with an mmu can do a vfork() just fine, so if you've cleared that it's ok to 
use it there, there's no real reason for not to just do it all the time.  In 
fact, being consistent means you have a single codepath and the same behavior 
on uClinux as everywhere else.

Rob



More information about the Dropbear mailing list