Skip to content

Commit

Permalink
Merge pull request #2 from oscar-system/bl/sigchld
Browse files Browse the repository at this point in the history
fix ExecuteProcess return value and disable sigchld handler
  • Loading branch information
fingolfin authored Apr 19, 2022
2 parents 2dc8a31 + 6e62777 commit 44d4081
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/GAP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ function initialize(argv::Vector{String})
# TODO: turn this into a proper libgap API
unsafe_store!(cglobal((:SyLoadSystemInitFile, libgap), Int64), 0)

# remember sigchld handler
if Sys.isbsd() || Sys.islinux()
sigchld = Sys.isbsd() ? 20 : 17
# nullptr == SIG_DFL
prev_sigchld_hdl = ccall(:signal, Ptr{Cvoid}, (Cint, Ptr{Cvoid}), sigchld, Ptr{Cvoid}(0))
end

ccall(
(:GAP_Initialize, libgap),
Cvoid,
Expand All @@ -107,6 +114,13 @@ function initialize(argv::Vector{String})
handle_signals,
)

# restore previous sigchld handler
# the one from gap should not be necessary with the replaced ExecuteProcess
# it also interferes badly with julia subprocess handling on macos because of the waitpid(-1)
if Sys.isbsd() || Sys.islinux()
gap_chld_hdl = ccall(:signal, Ptr{Cvoid}, (Cint, Ptr{Cvoid}), sigchld, prev_sigchld_hdl)
end

# HACK HACK HACK workaround
Base.GC.gc(true)

Expand Down

0 comments on commit 44d4081

Please sign in to comment.