add system
This commit is contained in:
parent
232133b5a9
commit
8c0bd33e0b
|
@ -0,0 +1,21 @@
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
int system(const char * command) {
|
||||||
|
char * args[] = {
|
||||||
|
"/bin/sh",
|
||||||
|
"-c",
|
||||||
|
(char *)command,
|
||||||
|
NULL,
|
||||||
|
};
|
||||||
|
pid_t pid = fork();
|
||||||
|
if (!pid) {
|
||||||
|
execvp(args[0], args);
|
||||||
|
exit(1);
|
||||||
|
} else {
|
||||||
|
int status;
|
||||||
|
waitpid(pid, &status, 0);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue