0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-09 01:18:47 +00:00
OI-codes/LibreOJ/6/data/runner.c
2022-09-17 16:23:49 +08:00

32 lines
500 B (Stored with Git LFS)
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);
}
}