Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fork error handling #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions _posts/2018-03-31-in-memory-only-elf-execution.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ exit (say, run it multiple times), it's the way to go. In general, using
```perl
while ($keep_going) {
my $pid = fork();
if (-1 == $pid) { # Error
if (not defined $pid) { # Error
die "fork: $!";
}
if (0 == $pid) { # Child
Expand All @@ -214,7 +214,7 @@ terminate:
```perl
# Spawn child
my $pid = fork();
if (-1 == $pid) { # Error
if (not defined $pid) { # Error
die "fork1: $!";
}
if (0 != $pid) { # Parent terminates
Expand All @@ -227,7 +227,7 @@ if (-1 == syscall(112)) {

# Spawn grandchild
$pid = fork();
if (-1 == $pid) { # Error
if (not defined $pid) { # Error
die "fork2: $!";
}
if (0 != $pid) { # Child terminates
Expand Down