ref: 8da361bb89c76cf969d6c85f4364cb84475938cc
dir: /plan9.c/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <ctype.h>
#include <sys/wait.h>
#include <utf.h>
#include "awk.h"
wint_t
towupper(wint_t r)
{
return toupperrune(r);
}
wint_t
towlower(wint_t r)
{
return tolowerrune(r);
}
int
system(const char *s) /* ape using ape/sh breaks tests */
{
int w, status;
pid_t pid;
if(!s)
return 1;
pid = fork();
if(pid == 0) {
execl("/bin/rc", "rc", "-c", s, NULL);
_exit(1);
}
if(pid < 0)
return -1;
for(;;) {
w = wait(&status);
if(w == -1 || w == pid)
break;
}
if(w == -1)
return w;
return status;
}