Mercurial > hg > toybox
comparison toys/posix/xargs.c @ 1327:85f297591693 draft
Introduce xfork() and make commands use it, and make some WEXITSTATUS() use WIFEXITED() and WTERMSIG()+127.
author | Rob Landley <rob@landley.net> |
---|---|
date | Sat, 31 May 2014 12:33:24 -0500 |
parents | e1f30cbf79f9 |
children |
comparison
equal
deleted
inserted
replaced
1326:78a3eaf5555f | 1327:85f297591693 |
---|---|
164 TT.bytes = bytes; | 164 TT.bytes = bytes; |
165 if (dlist) dlist->prev->next = 0; | 165 if (dlist) dlist->prev->next = 0; |
166 for (dtemp = dlist; dtemp; dtemp = dtemp->next) | 166 for (dtemp = dlist; dtemp; dtemp = dtemp->next) |
167 handle_entries(dtemp->data, out+entries); | 167 handle_entries(dtemp->data, out+entries); |
168 | 168 |
169 pid_t pid=fork(); | 169 pid_t pid=xfork(); |
170 if (!pid) { | 170 if (!pid) { |
171 xclose(0); | 171 xclose(0); |
172 open("/dev/null", O_RDONLY); | 172 open("/dev/null", O_RDONLY); |
173 xexec(out); | 173 xexec(out); |
174 } | 174 } |
175 waitpid(pid, &status, 0); | 175 waitpid(pid, &status, 0); |
176 status = WEXITSTATUS(status); | 176 status = WIFEXITED(status) ? WEXITSTATUS(status) : WTERMSIG(status)+127; |
177 | 177 |
178 // Abritrary number of execs, can't just leak memory each time... | 178 // Abritrary number of execs, can't just leak memory each time... |
179 while (dlist) { | 179 while (dlist) { |
180 struct double_list *dtemp = dlist->next; | 180 struct double_list *dtemp = dlist->next; |
181 | 181 |