From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/2944 Path: news.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general,gmane.linux.toybox Subject: Re: toybox: Rough edges in pending Date: Tue, 19 Mar 2013 12:09:39 +0100 Message-ID: <20130319110939.GJ19010@port70.net> References: <20130318235043.7e89ec83.idunham@lavabit.com> <20130319094225.GI19010@port70.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1363691396 24489 80.91.229.3 (19 Mar 2013 11:09:56 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 19 Mar 2013 11:09:56 +0000 (UTC) Cc: toybox@lists.landley.net To: musl@lists.openwall.com Original-X-From: musl-return-2945-gllmg-musl=m.gmane.org@lists.openwall.com Tue Mar 19 12:10:22 2013 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1UHuQp-0004ZW-Mr for gllmg-musl@plane.gmane.org; Tue, 19 Mar 2013 12:10:15 +0100 Original-Received: (qmail 15462 invoked by uid 550); 19 Mar 2013 11:09:52 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 15440 invoked from network); 19 Mar 2013 11:09:51 -0000 Content-Disposition: inline In-Reply-To: <20130319094225.GI19010@port70.net> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:2944 gmane.linux.toybox:266 Archived-At: * Szabolcs Nagy [2013-03-19 10:42:25 +0100]: > * Isaac Dunham [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 > > 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 either exec or _exit should be called after vfork but xexec calls toy_exec that runs ls in-place then calls exit (so the exit lock gets locked hence the deadlock when the parent tries to exit) void xexec(char **argv) { toy_exec(argv); execvp(argv[0], argv); perror_exit("exec %s", argv[0]); } void toy_exec(char *argv[]) { struct toy_list *which; which = toy_find(argv[0]); if (!which) return; toy_init(which, argv); toys.which->toy_main(); if (fflush(NULL) || ferror(stdout)) perror_exit("write"); exit(toys.exitval); }