Skip to content

Commit

Permalink
Refactor changes to one method
Browse files Browse the repository at this point in the history
  • Loading branch information
cyangle committed Nov 27, 2023
1 parent f10f63d commit 7d11346
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
7 changes: 0 additions & 7 deletions src/crystal/system/unix/process.cr
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@ struct Crystal::System::Process
end

def wait
{% if flag?(:interpreted) %}
# Block interpreter until child process is terminated
r_pid = LibC.waitpid(pid, out exit_code, 0)
@channel.send(exit_code)
# Close channel properly
@channel.close
{% end %}
@channel.receive
end

Expand Down
8 changes: 4 additions & 4 deletions src/crystal/system/unix/signal.cr
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,10 @@ module Crystal::System::SignalChildHandler
def self.wait(pid : LibC::PidT) : Channel(Int32)
channel = Channel(Int32).new(1)
{% if flag?(:interpreted) %}
# Returns channel immediately when interpreted
# Waiting for child process in interpreted code
# does not rely on signal SIGCHLD and it's handled
# in ::Crystal::System::Process.wait
# Blocking wait until child process exits
r_pid = LibC.waitpid(pid, out exit_code, 0)
channel.send(exit_code)
channel.close
return channel
{% end %}

Expand Down

0 comments on commit 7d11346

Please sign in to comment.