On 03/19/2013 06:09:39 AM, Szabolcs Nagy wrote:
* Szabolcs Nagy <[email protected]> [2013-03-19 10:42:25 +0100]:
> * Isaac Dunham <[email protected]> [2013-03-18 23:50:43 -0700]:
> > execve("./toybox-musl", ["./toybox-musl", "sh", "-c", "ls"], [/*
22 vars */]) = 0
> ...
> > ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B9600 opost isig icanon
echo ...}) = 0
> > vfork(Config.in README kconfig scripts toybox_unstripped
toys.h
> > LICENSE configure lib toybox toynet.h www
> > Makefile generated main.c toybox-musl toys
> > ) = 27832
> > --- SIGCHLD (Child exited) @ 0 (0) ---
> > wait4(27832, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) =
27832
> > pause(^C <unfinished ...>
>
> exit tries to flush some stdio buffers but it is locked
>
> maybe an issue around the way vfork is used by the shell
this is what toybox sh does:
cmd->pid = vfork();
if (!cmd->pid) xexec(cmd->argv);
else waitpid(cmd->pid, &status, 0);
it's an incorrect use of vfork
It is indeed. I was going to add some plumbing to xexec() to exec
/proc/self/exe in the internal toy called from toysh case, but toysh is
unfinished and I'm not sure it's the best approach and potentially
implementing the nofork logic with longjmp() for error handling works
into that, although I have to prototype bits of that to figure out
whether it's worth the effort.
(It's complicated. In bash you can't ctrl-z to suspend "read" because
it's a shell builtin and doesn't have a separate process context to
suspend, even though it can block. I feel it _should_ be possible to
suspend this but that involves potentially calling fork() from the
ctrl-z handler and is the shell not letting you do something obvious
better than complicating the implementation? There's _details_ to
getting this all right, and I haven't reopened the toysh can of worms
because I'd need more than a month to reach the next good stopping
point. The first week of which is a close re-reading of the SUSv4 shell
stuff and the bash man page and digging up my old test cases. I have
lots of lower hanging fruit to clear first.)
Rob
_______________________________________________
Toybox mailing list
[email protected]
http://lists.landley.net/listinfo.cgi/toybox-landley.net