0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-27 10:51:59 +00:00
OI-codes/LibreOJ/6/data/runner.c

32 lines
500 B
C
Raw Normal View History

2022-05-28 12:25:28 +00:00
#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);
}
}