[BusyBox] new version xargs

Glenn McGrath bug1 at optushome.com.au
Tue Nov 12 04:56:03 UTC 2002


On Mon, 11 Nov 2002 12:56:33 +0300
"Vladimir N. Oleynik" <dzo at simtreas.ru> wrote:

> I think, idea from my xargs_exec may be true algorith for use for
> new run_part() libbb function. No MMU mashines can use vfork but
> can`t use fork().
> 
> 
>         int pid;
> +	int common[4];	/* common vfork stack */
> 
> +	common[0] = 0;
> -        if ((pid = fork()) < 0) {
> +        if ((pid = vfork()) < 0) {
>              perror_msg_and_die("failed to vfork");
>         } else if (!pid) {
>               execv(args[0], args);
> +	      common[0]=errno;
> +	      _exit(1);
> -              perror_msg_and_die("failed to exec %s", args[0]);
>         }
> +	if(common[0]) {
> +		errno = common[0];
> +       	perror_msg_and_die("failed to exec %s", args[0]);
> +	}
>         waitpid(pid, &result, 0);
> 

When i try this i get warnings, i dont know vfork very well, i think i
would have to make it a seperate function.

How about we move xargs_exec() into libbb, so both xargs and run_part (and
maybe other applets) can use it, the only difference is run_part uses
waitpid(pid, &result, 0) instead of wait(NULL), and needs to parse result
to display error messages. Maybe we could return(result) ?

/home/bug1/busybox/orig/busybox/libbb/run_parts.c: In function
`run_parts':
/home/bug1/busybox/orig/busybox/libbb/run_parts.c:88: warning: variable
`i' might be clobbered by `longjmp' or `vfork'
/home/bug1/busybox/orig/busybox/libbb/run_parts.c:89: warning: variable
`exitstatus' might be clobbered by `longjmp' or `vfork


Glenn



More information about the busybox mailing list