Skip to content

Commit 13c8091

Browse files
committed
Fixed execl() invocation.
1 parent de4c98b commit 13c8091

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

docs/class-assignments/labs-assignment-2018.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,10 @@ use fork(2).
8282
You must NOT exec any shell from your code. I.e. if you have a pipeline
8383
"cat /etc/passwd | wc -l", the solution is not the following:
8484

85-
if (fork() == 0)
86-
execl("/bin/sh", "sh", "-c", "cat /etc/passwd | wc -l");
85+
if (fork() == 0) {
86+
execl("/bin/sh", "sh", "-c", "cat /etc/passwd | wc -l",
87+
NULL);
88+
}
8789

8890
You really have to fork a new process for each command in a pipeline,
8991
and connect them together with pipes.

0 commit comments

Comments
 (0)