ref: 2aee89298cbbf5c1b4d50e70733b52ae75c706fd
dir: /libnpe/system.c/
#include <npe.h>
#undef waitpid
int
system(char *s)
{
int status;
Waitmsg *w;
pid_t pid;
char cmd[30], *oty;
if(!s)
return 1; /* a command interpreter is available */
pid = fork();
if(pid == 0){
oty = getenv("cputype");
if(!oty)
return -1;
snprintf(cmd, sizeof cmd, "/%s/bin/rc", oty);
execl(cmd, "rc", "-c", s, NULL);
exits(nil);
}
if(pid < 0){
return -1;
}
for(;;){
w = wait();
if(w == nil || w->pid == pid)
break;
}
status = -1;
if(w != nil){
status = w->msg[0] != 0;
free(w);
}
return status;
}