0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-24 00:28:48 +00:00
OI-codes/LibreOJ/6/data/runner.c

32 lines
500 B
C

#include <unistd.h>
int main() {
int f1[2], f2[2];
pipe(f1);
pipe(f2);
if (!fork()) {
// Child
dup2(STDIN_FILENO, f1[0]);
dup2(STDOUT_FILENO, f2[1]);
char *cmd = "./test";
char *argv[2];
argv[0] = "./test";
argv[1] = NULL;
execvp(cmd, argv);
}
if (!fork()) {
// Child
dup2(STDIN_FILENO, f2[0]);
dup2(STDOUT_FILENO, f1[1]);
char *cmd = "./iat";
char *argv[2];
argv[0] = "./iat";
argv[1] = NULL;
execvp(cmd, argv);
}
}