better exit handling
This commit is contained in:
parent
daefa1a92f
commit
3d867865ef
2 changed files with 32 additions and 3 deletions
|
|
@ -111,6 +111,34 @@ threadspawn(int fd[3], char *cmd, char *argv[])
|
||||||
return _runthreadspawn(fd, cmd, 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
|
int
|
||||||
_threadexec(Channel *cpid, int fd[3], char *cmd, char *argv[])
|
_threadexec(Channel *cpid, int fd[3], char *cmd, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
#include "threadimpl.h"
|
#include "threadimpl.h"
|
||||||
|
|
||||||
|
#undef exits
|
||||||
|
#undef _exits
|
||||||
|
|
||||||
static pthread_mutex_t initmutex = PTHREAD_MUTEX_INITIALIZER;
|
static pthread_mutex_t initmutex = PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -136,10 +139,8 @@ _pthreadinit(void)
|
||||||
static struct utsname un;
|
static struct utsname un;
|
||||||
pthread_t id;
|
pthread_t id;
|
||||||
|
|
||||||
if(uname(&un) < 0){
|
if(uname(&un) < 0)
|
||||||
fprint(2, "warning: uname failed: %r\n");
|
fprint(2, "warning: uname failed: %r\n");
|
||||||
goto Okay;
|
|
||||||
}
|
|
||||||
if(strcmp(un.sysname, "Linux") == 0){
|
if(strcmp(un.sysname, "Linux") == 0){
|
||||||
/*
|
/*
|
||||||
* Want to distinguish between the old LinuxThreads pthreads
|
* Want to distinguish between the old LinuxThreads pthreads
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue