aboutsummaryrefslogtreecommitdiff
path: root/sys/cmd/rc/rc.h
diff options
context:
space:
mode:
Diffstat (limited to 'sys/cmd/rc/rc.h')
-rw-r--r--sys/cmd/rc/rc.h58
1 files changed, 31 insertions, 27 deletions
diff --git a/sys/cmd/rc/rc.h b/sys/cmd/rc/rc.h
index 606ca7b..d3fc7bf 100644
--- a/sys/cmd/rc/rc.h
+++ b/sys/cmd/rc/rc.h
@@ -3,19 +3,6 @@
#include <u.h>
#include <libn.h>
-/*
- * A thread functions much like a GNU job -> it's just a simple execution stack
- * We just need to modify the following datastructures:
- *
- * 1. Need to store the list of all "active" and "foreground" threads
- * - Right now we just have Thread *proc which is the running process.
- * - Need to move this to a linked list (how does this interact with the link?)
- * - Linked list stores the independent roots of each individual process tree
- * 2. Child pids are stored inside waitpid right now. Need to associate this more explictly with a thread.
- * 3. Wait needs to be generalized to act on threads.
- * 4. our "start" function is equivalent to the launch_job function
- * 5. running the interpreter runs the launch_process implicitly (with forks called as interpreter functions)
- */
// -----------------------------------------------------------------------
// types
@@ -36,10 +23,28 @@ struct Io
char *b, *e, buf[];
};
+enum
+{
+ Rappend,
+ Rwrite,
+ Rread,
+ Rhere,
+ Rdup,
+ Ropen,
+ Rclose,
+ Rrdwr
+};
+
struct Tree
{
int type;
- char *str;
+ union{
+ char *str; // Tword
+ struct {
+ ushort type; // Tpipe, Tredir, Tdup
+ int fd[2];
+ } redir;
+ };
Tree *child[3];
Tree *link;
};
@@ -79,13 +84,6 @@ struct Var
Var *link;
};
-enum
-{
- Rclose,
- Rdup,
- Ropen,
-};
-
struct Redir
{
char type; /* what to do */
@@ -122,11 +120,14 @@ struct Thread
List *args; // argument stack
Var *local; // local variables
- Redir *redir; // list of redirections
+ struct {
+ Redir *start;
+ Redir *end;
+ } redir; // list of redirections
struct {
- ushort i : 1;
- ushort eof : 1;
+ ushort user : 1;
+ ushort eof : 1;
} flag;
struct {
@@ -138,8 +139,8 @@ struct Thread
int pid, pgid, status;
long line;
- Thread *link; // process we return to
- Thread *next; // next job
+ Thread *caller; // process we return to
+ Thread *link; // next job
};
struct Shell
@@ -197,12 +198,15 @@ Tree *maketree2(int, Tree*, Tree*);
Tree *maketree3(int, Tree*, Tree*, Tree*);
Tree *token(int, char *);
-Tree *hangchild1(Tree *, Tree *, int at);
+Tree *hangchild1(Tree *, Tree *, int);
+Tree *hangchild2(Tree *, Tree *, int, Tree *, int);
+Tree *hangepilog(Tree *, Tree*);
void freeparsetree(void);
/* sys.c */
void initenv(void);
+void redirect(struct Redir *);
void execute(Word *, Word*);
/* wait.c */