File tree 1 file changed +7
-6
lines changed
library/std/src/sys/pal/unix
1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -140,18 +140,19 @@ mod imp {
140
140
unsafe { sigaction ( signal, ptr:: null_mut ( ) , & mut action) } ;
141
141
// Configure our signal handler if one is not already set.
142
142
if action. sa_sigaction == SIG_DFL {
143
+ if !NEED_ALTSTACK . load ( Ordering :: Relaxed ) {
144
+ // haven't set up our sigaltstack yet
145
+ NEED_ALTSTACK . store ( true , Ordering :: Relaxed ) ;
146
+ let handler = unsafe { make_handler ( true ) } ;
147
+ MAIN_ALTSTACK . store ( handler. data , Ordering :: Relaxed ) ;
148
+ mem:: forget ( handler) ;
149
+ }
143
150
action. sa_flags = SA_SIGINFO | SA_ONSTACK ;
144
151
action. sa_sigaction = signal_handler as sighandler_t ;
145
152
// SAFETY: only overriding signals if the default is set
146
153
unsafe { sigaction ( signal, & action, ptr:: null_mut ( ) ) } ;
147
- NEED_ALTSTACK . store ( true , Ordering :: Relaxed ) ;
148
154
}
149
155
}
150
-
151
- // SAFETY: mutates our signal stack. shouldn't we install this first?
152
- let handler = unsafe { make_handler ( true ) } ;
153
- MAIN_ALTSTACK . store ( handler. data , Ordering :: Relaxed ) ;
154
- mem:: forget ( handler) ;
155
156
}
156
157
157
158
/// # Safety
You can’t perform that action at this time.
0 commit comments