File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -200,4 +200,11 @@ impl<T: EventClosure> EventDispatcher<T> {
200
200
}
201
201
}
202
202
}
203
+
204
+ /// Unregister all the handlers created by the dispatcher.
205
+ pub ( super ) fn unregister_handlers ( self ) {
206
+ for handler in self . signal_handlers {
207
+ handler. unregister ( ) ;
208
+ }
209
+ }
203
210
}
Original file line number Diff line number Diff line change @@ -54,6 +54,8 @@ pub(super) fn exec_pty(
54
54
// enabled or if sudo is running in background.
55
55
// FIXME (ogsudo): Copy terminal settings from `/dev/tty` to the pty.
56
56
// FIXME (ogsudo): Start in raw mode unless we're part of a pipeline
57
+ // FIXME: it would be better if we didn't create the dispatcher before the fork and managed
58
+ // to block all the signals instead.
57
59
let mut dispatcher = EventDispatcher :: < ParentClosure > :: new ( ) ?;
58
60
59
61
let monitor_pid = fork ( ) . map_err ( |err| {
@@ -66,6 +68,10 @@ pub(super) fn exec_pty(
66
68
drop ( pty. leader ) ;
67
69
drop ( backchannels. parent ) ;
68
70
71
+ // Unregister all the handlers so `exec_monitor` can register new ones for the monitor
72
+ // process.
73
+ dispatcher. unregister_handlers ( ) ;
74
+
69
75
// If `exec_monitor` returns, it means we failed to execute the command somehow.
70
76
if let Err ( err) = exec_monitor ( pty. follower , command, & mut backchannels. monitor ) {
71
77
if let Err ( err) = backchannels. monitor . send ( & err. into ( ) ) {
You can’t perform that action at this time.
0 commit comments