From 47e3d475df6244a48b73421cd4210b64c392df8d Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Tue, 19 Oct 2021 09:35:59 -0700 Subject: feat(rc): cleaner process watching for each job --- sys/cmd/rc/rc.h | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) (limited to 'sys/cmd/rc/rc.h') diff --git a/sys/cmd/rc/rc.h b/sys/cmd/rc/rc.h index 9c6307f..ef7c18e 100644 --- a/sys/cmd/rc/rc.h +++ b/sys/cmd/rc/rc.h @@ -93,6 +93,22 @@ struct Redir struct Redir *link; /* what else to do (reverse order) */ }; +enum +{ + PNil, + PRun, + PStop, + PSig, + PAgain, + PDone, +}; + +struct WaitItem +{ + int pid; + ushort status; +}; + struct Thread { struct { @@ -109,21 +125,19 @@ struct Thread Redir *redir; // list of redirections struct { - ushort i : 1; - ushort eof : 1; - ushort stop : 1; - ushort done : 1; - ushort again : 1; - } flag; // flags for process + ushort i : 1; + ushort eof : 1; + } flag; struct { - int len, cap, *pid; + ushort status; + int len, cap; + struct WaitItem *on; } wait; int pid, pgid, status; long line; - Tree *nodes; // memory allocation Thread *link; // process we return to Thread *next; // next job }; @@ -131,6 +145,7 @@ struct Thread struct Shell { int pid; + Io *err; int status; int interactive; Thread *jobs; @@ -140,9 +155,7 @@ struct Shell // globals extern Shell shell; - -extern Thread *proc; -extern Io *errio; +extern Thread *runner; extern Code *compiled; // ----------------------------------------------------------------------- @@ -203,6 +216,7 @@ void killzombies(void); Thread *getjob(int, int*); void addjob(Thread *); void deljob(Thread *); +void wakeup(Thread *); void report(Thread *, int); void foreground(Thread *, int); -- cgit v1.2.1