Skip to content

Commit be07ddc

Browse files
authored
Fix dup() -> dup2()
1 parent 4bcbc74 commit be07ddc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

CS110NotesCollection/Topic 2 Multiprocessing (3).md

+2-2
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ subprocess_t subprocess(const char *command) {
194194
195195
/* redirect the child's stdin FD to the pipe's reading end,
196196
and de-associate fd[0] from the reading end */
197-
dup(fds[0], STDIN_FILENO);
197+
dup2(fds[0], STDIN_FILENO);
198198
close(fds[0]);
199199
200200
/* now, execute the intended program (/bin/sh) by execvp() */
@@ -216,4 +216,4 @@ subprocess_t subprocess(const char *command) {
216216
```
217217
> Note that if `execvp()` succeeds, then the rest of the code is NOT executed, as the calling process is completely overwritten and rebooted by another program.
218218
219-
###### EOF
219+
###### EOF

0 commit comments

Comments
 (0)