cmd: s/pipe()/pipe2()/g

parent 0e8afcc0
...@@ -303,8 +303,8 @@ int main(int argc, char *argv[]) ...@@ -303,8 +303,8 @@ int main(int argc, char *argv[])
int pid; int pid;
char *default_args[] = {"/bin/sh", NULL}; char *default_args[] = {"/bin/sh", NULL};
char buf[1]; char buf[1];
int pipe1[2], // child tells parent it has unshared int pipe_fds1[2], /* child tells parent it has unshared */
pipe2[2]; // parent tells child it is mapped and may proceed pipe_fds2[2]; /* parent tells child it is mapped and may proceed */
lxc_log_fd = STDERR_FILENO; lxc_log_fd = STDERR_FILENO;
...@@ -360,15 +360,15 @@ int main(int argc, char *argv[]) ...@@ -360,15 +360,15 @@ int main(int argc, char *argv[])
if (argc < 1) if (argc < 1)
argv = default_args; argv = default_args;
if (pipe(pipe1) < 0 || pipe(pipe2) < 0) { if (pipe2(pipe_fds1, O_CLOEXEC) < 0 || pipe2(pipe_fds2, O_CLOEXEC) < 0) {
perror("pipe"); perror("pipe");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if ((pid = fork()) == 0) { if ((pid = fork()) == 0) {
// Child. // Child.
close(pipe1[0]); close(pipe_fds1[0]);
close(pipe2[1]); close(pipe_fds2[1]);
opentty(ttyname0, 0); opentty(ttyname0, 0);
opentty(ttyname1, 1); opentty(ttyname1, 1);
opentty(ttyname2, 2); opentty(ttyname2, 2);
...@@ -379,11 +379,11 @@ int main(int argc, char *argv[]) ...@@ -379,11 +379,11 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
buf[0] = '1'; buf[0] = '1';
if (write(pipe1[1], buf, 1) < 1) { if (write(pipe_fds1[1], buf, 1) < 1) {
perror("write pipe"); perror("write pipe");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if (read(pipe2[0], buf, 1) < 1) { if (read(pipe_fds2[0], buf, 1) < 1) {
perror("read pipe"); perror("read pipe");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
...@@ -392,14 +392,14 @@ int main(int argc, char *argv[]) ...@@ -392,14 +392,14 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
close(pipe1[1]); close(pipe_fds1[1]);
close(pipe2[0]); close(pipe_fds2[0]);
return do_child((void*)argv); return do_child((void*)argv);
} }
close(pipe1[1]); close(pipe_fds1[1]);
close(pipe2[0]); close(pipe_fds2[0]);
if (read(pipe1[0], buf, 1) < 1) { if (read(pipe_fds1[0], buf, 1) < 1) {
perror("read pipe"); perror("read pipe");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
...@@ -409,7 +409,7 @@ int main(int argc, char *argv[]) ...@@ -409,7 +409,7 @@ int main(int argc, char *argv[])
if (lxc_map_ids(&active_map, pid)) if (lxc_map_ids(&active_map, pid))
fprintf(stderr, "error mapping child\n"); fprintf(stderr, "error mapping child\n");
if (write(pipe2[1], buf, 1) < 0) { if (write(pipe_fds2[1], buf, 1) < 0) {
perror("write to pipe"); perror("write to pipe");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment