Skip to content

Commit

Permalink
Fix: Add SA_RESTART flag to sigaction syscall (#14351)
Browse files Browse the repository at this point in the history
  • Loading branch information
ysbaddaden authored Mar 8, 2024
1 parent b79ea16 commit d15649f
Show file tree
Hide file tree
Showing 16 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/crystal/system/unix/signal.cr
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ module Crystal::System::Signal
unless @@handlers[signal]?
@@sigset << signal
action = LibC::Sigaction.new

# restart some interrupted syscalls (read, write, accept, ...) instead
# of returning EINTR:
action.sa_flags = LibC::SA_RESTART

action.sa_sigaction = LibC::SigactionHandlerT.new do |value, _, _|
writer.write_bytes(value) unless writer.closed?
end
Expand Down
1 change: 1 addition & 0 deletions src/lib_c/aarch64-android/c/signal.cr
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ lib LibC
end

SA_ONSTACK = 0x08000000
SA_RESTART = 0x10000000
SA_SIGINFO = 0x00000004

struct SiginfoT
Expand Down
1 change: 1 addition & 0 deletions src/lib_c/aarch64-darwin/c/signal.cr
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ lib LibC
SIG_IGN = SighandlerT.new(Pointer(Void).new(1_u64), Pointer(Void).null)

SA_ONSTACK = 0x0001
SA_RESTART = 0x0002
SA_SIGINFO = 0x0040

struct SiginfoT
Expand Down
1 change: 1 addition & 0 deletions src/lib_c/aarch64-linux-gnu/c/signal.cr
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ lib LibC
end

SA_ONSTACK = 0x08000000
SA_RESTART = 0x10000000
SA_SIGINFO = 0x00000004

struct SiginfoT
Expand Down
1 change: 1 addition & 0 deletions src/lib_c/aarch64-linux-musl/c/signal.cr
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ lib LibC
end

SA_ONSTACK = 0x08000000
SA_RESTART = 0x10000000
SA_SIGINFO = 0x00000004

struct SiginfoT
Expand Down
1 change: 1 addition & 0 deletions src/lib_c/arm-linux-gnueabihf/c/signal.cr
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ lib LibC
end

SA_ONSTACK = 0x08000000
SA_RESTART = 0x10000000
SA_SIGINFO = 0x00000004

struct SiginfoT
Expand Down
1 change: 1 addition & 0 deletions src/lib_c/i386-linux-gnu/c/signal.cr
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ lib LibC
end

SA_ONSTACK = 0x08000000
SA_RESTART = 0x10000000
SA_SIGINFO = 0x00000004

struct SiginfoT
Expand Down
1 change: 1 addition & 0 deletions src/lib_c/i386-linux-musl/c/signal.cr
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ lib LibC
end

SA_ONSTACK = 0x08000000
SA_RESTART = 0x10000000
SA_SIGINFO = 0x00000004

struct SiginfoT
Expand Down
1 change: 1 addition & 0 deletions src/lib_c/x86_64-darwin/c/signal.cr
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ lib LibC
SIG_IGN = SighandlerT.new(Pointer(Void).new(1_u64), Pointer(Void).null)

SA_ONSTACK = 0x0001
SA_RESTART = 0x0002
SA_SIGINFO = 0x0040

struct SiginfoT
Expand Down
1 change: 1 addition & 0 deletions src/lib_c/x86_64-dragonfly/c/signal.cr
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ lib LibC
end

SA_ONSTACK = 0x0001
SA_RESTART = 0x0002
SA_SIGINFO = 0x0040

struct Sigval
Expand Down
1 change: 1 addition & 0 deletions src/lib_c/x86_64-freebsd/c/signal.cr
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ lib LibC
end

SA_ONSTACK = 0x0001
SA_RESTART = 0x0002
SA_SIGINFO = 0x0040

struct Sigval
Expand Down
1 change: 1 addition & 0 deletions src/lib_c/x86_64-linux-gnu/c/signal.cr
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ lib LibC
end

SA_ONSTACK = 0x08000000
SA_RESTART = 0x10000000
SA_SIGINFO = 0x00000004

struct SiginfoT
Expand Down
1 change: 1 addition & 0 deletions src/lib_c/x86_64-linux-musl/c/signal.cr
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ lib LibC
end

SA_ONSTACK = 0x08000000
SA_RESTART = 0x10000000
SA_SIGINFO = 0x00000004

struct SiginfoT
Expand Down
1 change: 1 addition & 0 deletions src/lib_c/x86_64-netbsd/c/signal.cr
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ lib LibC
end

SA_ONSTACK = 0x0001
SA_RESTART = 0x0002
SA_SIGINFO = 0x0040

struct SiginfoT
Expand Down
1 change: 1 addition & 0 deletions src/lib_c/x86_64-openbsd/c/signal.cr
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ lib LibC
SIG_IGN = SighandlerT.new(Pointer(Void).new(1_u64), Pointer(Void).null)

SA_ONSTACK = 0x0001
SA_RESTART = 0x0002
SA_SIGINFO = 0x0040

struct SiginfoT
Expand Down
1 change: 1 addition & 0 deletions src/lib_c/x86_64-solaris/c/signal.cr
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ lib LibC
end

SA_ONSTACK = 0x00000001
SA_RESTART = 0x00000004
SA_SIGINFO = 0x00000008

struct SiginfoT
Expand Down

0 comments on commit d15649f

Please sign in to comment.