File tree 2 files changed +19
-3
lines changed
2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -164,7 +164,6 @@ pub(super) fn exec_monitor(
164
164
// Disable nonblocking assetions as we will not poll the backchannel anymore.
165
165
closure. backchannel . set_nonblocking_assertions ( false ) ;
166
166
167
- std:: thread:: sleep ( std:: time:: Duration :: from_millis ( 10 ) ) ;
168
167
match reason {
169
168
StopReason :: Break ( err) => match err. try_into ( ) {
170
169
Ok ( msg) => {
@@ -183,6 +182,14 @@ pub(super) fn exec_monitor(
183
182
}
184
183
}
185
184
185
+ // Wait for the parent to give us red light before shutting down. This avoids missing
186
+ // output when the monitor exits too quickly.
187
+ let event = retry_while_interrupted ( || backchannel. recv ( ) ) . map_err ( |err| {
188
+ dev_warn ! ( "cannot receive red light from parent: {err}" ) ;
189
+ err
190
+ } ) ?;
191
+ debug_assert_eq ! ( event, MonitorMessage :: ExecCommand ) ;
192
+
186
193
// FIXME (ogsudo): The tty is restored here if selinux is available.
187
194
188
195
// We call `_exit` instead of `exit` to avoid flushing the parent's IO streams by accident.
Original file line number Diff line number Diff line change @@ -353,10 +353,19 @@ impl ParentClosure {
353
353
}
354
354
355
355
fn run ( & mut self , registry : EventRegistry < Self > ) -> io:: Result < ExitReason > {
356
- match registry. event_loop ( self ) {
356
+ let result = match registry. event_loop ( self ) {
357
357
StopReason :: Break ( err) | StopReason :: Exit ( ParentExit :: Backchannel ( err) ) => Err ( err) ,
358
358
StopReason :: Exit ( ParentExit :: Command ( exit_reason) ) => Ok ( exit_reason) ,
359
- }
359
+ } ;
360
+ // Send red light to the monitor after processing all events
361
+ retry_while_interrupted ( || self . backchannel . send ( & MonitorMessage :: ExecCommand ) ) . map_err (
362
+ |err| {
363
+ dev_error ! ( "cannot send red light to monitor: {err}" ) ;
364
+ err
365
+ } ,
366
+ ) ?;
367
+
368
+ result
360
369
}
361
370
362
371
/// Read an event from the backchannel and return the event if it should break the event loop.
You can’t perform that action at this time.
0 commit comments