@@ -23,7 +23,7 @@ use alloc::sync::{Arc, Weak};
23
23
use spin:: RwLock ;
24
24
25
25
use core:: cell:: UnsafeCell ;
26
- use core:: sync:: atomic:: { AtomicIsize , AtomicU8 , AtomicUsize , Ordering } ;
26
+ use core:: sync:: atomic:: { AtomicBool , AtomicIsize , AtomicU8 , AtomicUsize , Ordering } ;
27
27
28
28
use crate :: fs:: cache:: { DirCacheImpl , DirCacheItem } ;
29
29
use crate :: fs:: { self , FileSystem } ;
@@ -186,6 +186,7 @@ pub struct Task {
186
186
signals : Signals ,
187
187
188
188
executable : Mutex < Option < DirCacheItem > > ,
189
+ pending_io : AtomicBool ,
189
190
190
191
pub ( super ) link : intrusive_collections:: LinkedListLink ,
191
192
pub ( super ) clink : intrusive_collections:: LinkedListLink ,
@@ -227,6 +228,8 @@ impl Task {
227
228
link : Default :: default ( ) ,
228
229
clink : Default :: default ( ) ,
229
230
231
+ pending_io : AtomicBool :: new ( false ) ,
232
+
230
233
sleep_duration : AtomicUsize :: new ( 0 ) ,
231
234
exit_status : AtomicIsize :: new ( 0 ) ,
232
235
@@ -265,6 +268,7 @@ impl Task {
265
268
exit_status : AtomicIsize :: new ( 0 ) ,
266
269
267
270
executable : Mutex :: new ( None ) ,
271
+ pending_io : AtomicBool :: new ( false ) ,
268
272
269
273
children : Mutex :: new ( Default :: default ( ) ) ,
270
274
parent : Mutex :: new ( None ) ,
@@ -297,6 +301,7 @@ impl Task {
297
301
pid,
298
302
299
303
executable : Mutex :: new ( self . executable . lock ( ) . clone ( ) ) ,
304
+ pending_io : AtomicBool :: new ( false ) ,
300
305
301
306
children : Mutex :: new ( Default :: default ( ) ) ,
302
307
parent : Mutex :: new ( None ) ,
@@ -313,6 +318,14 @@ impl Task {
313
318
this
314
319
}
315
320
321
+ pub fn has_pending_io ( & self ) -> bool {
322
+ self . pending_io . load ( Ordering :: SeqCst )
323
+ }
324
+
325
+ pub fn set_pending_io ( & self , yes : bool ) {
326
+ self . pending_io . store ( yes, Ordering :: SeqCst )
327
+ }
328
+
316
329
pub fn signals ( & self ) -> & Signals {
317
330
& self . signals
318
331
}
@@ -379,17 +392,18 @@ impl Task {
379
392
if pid == -1 {
380
393
// wait for any child process if no specific process is requested.
381
394
//
382
- // NOTE: we collect all of the zombie list's process IDs instead of the children
383
- // list since the child could have been removed from the children list and become a zombie
384
- // before the parent had a chance to wait for it.
385
- let pids = self
395
+ // NOTE: we collect all of the zombie list's process IDs with the children
396
+ // list since the child could have been removed from the children list and
397
+ // become a zombie before the parent had a chance to wait for it.
398
+ let mut pids = self
386
399
. zombies
387
400
. list
388
401
. lock_irq ( )
389
402
. iter ( )
390
403
. map ( |e| e. pid ( ) . as_usize ( ) )
391
404
. collect :: < alloc:: vec:: Vec < _ > > ( ) ;
392
405
406
+ pids. extend ( self . children . lock_irq ( ) . iter ( ) . map ( |e| e. pid ( ) . as_usize ( ) ) ) ;
393
407
self . zombies . waitpid ( & pids, status)
394
408
} else {
395
409
self . zombies . waitpid ( & [ pid as _ ] , status)
@@ -536,7 +550,7 @@ impl Task {
536
550
parent. zombies . add_zombie ( self . this ( ) ) ;
537
551
538
552
if self . is_process_leader ( ) {
539
- parent. signal ( aero_syscall:: signal:: SIGCHLD ) ;
553
+ // parent.signal(aero_syscall::signal::SIGCHLD);
540
554
}
541
555
}
542
556
}
0 commit comments