source: trunk/src/ash-messup/shinstance.h@ 880

Last change on this file since 880 was 880, checked in by bird, 18 years ago

hacking...

File size: 5.5 KB
Line 
1/* $Id: $ */
2/** @file
3 *
4 * The shell instance and it's methods.
5 *
6 * Copyright (c) 2007 knut st. osmundsen <bird-src-spam@anduin.net>
7 *
8 *
9 * This file is part of kBuild.
10 *
11 * kBuild is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * kBuild is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with kBuild; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 *
25 */
26
27#include "shtypes.h"
28#include "shthread.h"
29
30/**
31 * One file.
32 */
33typedef struct shfile
34{
35 int fd; /**< The shell file descriptor number. */
36 int flags; /**< Open flags. */
37 intptr_t native; /**< The native file descriptor number. */
38} shfile;
39
40/**
41 * The file descriptor table for a shell.
42 */
43typedef struct shfdtab
44{
45 shmtx mtx; /**< Mutex protecting any operations on the table and it's handles. */
46 unsigned size; /**< The size of the table (number of entries). */
47 shfile *tab; /**< Pointer to the table. */
48} shfdtab;
49
50/**
51 * A shell instance.
52 *
53 * This is the core structure of the shell, it contains all
54 * the data associated with a shell process except that it's
55 * running in a thread and not a separate process.
56 */
57typedef struct shinstance
58{
59 struct shinstance *next; /**< The next shell instance. */
60 struct shinstance *prev; /**< The previous shell instance. */
61 struct shinstance *parent; /**< The parent shell instance. */
62 pid_t pid; /**< The (fake) process id of this shell instance. */
63 shtid tid; /**< The thread identifier of the thread for this shell. */
64 shfdtab fdtab; /**< The file descriptor table. */
65
66 /* error.h */
67 struct jmploc *handler;
68 int exception;
69 int exerrno;
70 int volatile suppressint;
71 int volatile intpending;
72
73 /* main.h */
74 int rootpid; /**< pid of main shell. */
75 int rootshell; /**< true if we aren't a child of the main shell. */
76 struct shinstance *psh_rootshell; /**< The root shell pointer. (!rootshell) */
77
78 /* trap.h */
79 int pendingsigs;
80
81 /* parse.h */
82 int tokpushback;
83 int whichprompt; /**< 1 == PS1, 2 == PS2 */
84
85 /* output.h */
86 struct output output;
87 struct output errout;
88 struct output memout;
89 struct output *out1;
90 struct output *out2;
91
92 /* options.h */
93 struct optent optlist[NOPTS];
94 char *minusc; /**< argument to -c option */
95 char *arg0; /**< $0 */
96 struct shparam shellparam; /**< $@ */
97 char **argptr; /**< argument list for builtin commands */
98 char *optionarg; /**< set by nextopt */
99 char *optptr; /**< used by nextopt */
100
101 /* var.h */
102 struct localvar *localvars;
103#if ATTY
104 struct var vatty;
105#endif
106 struct var vifs;
107 struct var vmail;
108 struct var vmpath;
109 struct var vpath;
110#ifdef _MSC_VER
111 struct var vpath2;
112#endif
113 struct var vps1;
114 struct var vps2;
115 struct var vps4;
116#ifndef SMALL
117 struct var vterm;
118 struct var vtermcap;
119 struct var vhistsize;
120#endif
121
122 /* myhistedit.h */
123 int displayhist;
124#ifndef SMALL
125 History *hist;
126 EditLine *el;
127#endif
128
129 /* memalloc.h */
130 char *stacknxt;
131 int stacknleft;
132 int sstrnleft;
133 int herefd;
134
135 /* jobs.h */
136 pid_t backgndpid; /**< pid of last background process */
137 int job_warning; /**< user was warned about stopped jobs */
138
139 /* input.h */
140 int plinno;
141 int parsenleft; /**< number of characters left in input buffer */
142 char *parsenextc; /**< next character in input buffer */
143 int init_editline; /**< 0 == not setup, 1 == OK, -1 == failed */
144
145 /* exec.h */
146 const char *pathopt; /**< set by padvance */
147
148 /* eval.h */
149 char *commandname; /**< currently executing command */
150 int exitstatus; /**< exit status of last command */
151 int back_exitstatus;/**< exit status of backquoted command */
152 struct strlist *cmdenviron; /**< environment for builtin command */
153 int funcnest;
154 int evalskip;
155
156 /* builtins.h */
157 const char *commandname;
158
159} shinstance;
160
161
162extern shinstance *create_root_shell(shinstance *inherit, int argc, char **argv);
163
Note: See TracBrowser for help on using the repository browser.