From 3d867865ef5663f640f7c607fadfd3fb0c0ac625 Mon Sep 17 00:00:00 2001 From: rsc Date: Tue, 18 Jan 2005 18:13:16 +0000 Subject: better exit handling --- src/libthread/exec.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/libthread/exec.c') diff --git a/src/libthread/exec.c b/src/libthread/exec.c index 43242cf0..bfd4f718 100644 --- a/src/libthread/exec.c +++ b/src/libthread/exec.c @@ -111,6 +111,34 @@ threadspawn(int fd[3], char *cmd, char *argv[]) return _runthreadspawn(fd, cmd, argv); } +int +threadspawnl(int fd[3], char *cmd, ...) +{ + char **argv, *s; + int n, pid; + va_list arg; + + va_start(arg, cmd); + for(n=0; va_arg(arg, char*) != nil; n++) + ; + n++; + va_end(arg); + + argv = malloc(n*sizeof(argv[0])); + if(argv == nil) + return -1; + + va_start(arg, cmd); + for(n=0; (s=va_arg(arg, char*)) != nil; n++) + argv[n] = s; + argv[n] = 0; + va_end(arg); + + pid = threadspawn(fd, cmd, argv); + free(argv); + return pid; +} + int _threadexec(Channel *cpid, int fd[3], char *cmd, char *argv[]) { -- cgit v1.2.3