Changeset 879 for trunk/src/ash-messup/main.c
- Timestamp:
- Apr 21, 2007, 8:33:35 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/ash-messup/main.c
r809 r879 85 85 STATIC union node *curcmd; 86 86 STATIC union node *prevcmd; 87 #if PROFILE88 short profile_buf[16384];89 extern int etext();90 #endif91 87 92 88 STATIC void read_profile(const char *); … … 105 101 main(int argc, char **argv) 106 102 { 103 shinstance *psh; 104 105 setlocale(LC_ALL, ""); 106 107 /* 108 * Create the root shell instance. 109 */ 110 psh = create_root_shell(NULL, argc, argv); 111 if (!psh) 112 return 2; 113 return shell_main(psh, argc); 114 } 115 116 int 117 shell_main(shinstance *psh, int argc, char **argv) 118 { 107 119 struct jmploc jmploc; 108 120 struct stackmark smark; … … 110 122 char *shinit; 111 123 112 setlocale(LC_ALL, "");113 114 #if PROFILE115 monitor(4, etext, profile_buf, sizeof profile_buf, 50);116 #endif117 124 state = 0; 118 125 if (setjmp(jmploc.loc)) { … … 166 173 goto state4; 167 174 } 168 handler = &jmploc;175 psh->handler = &jmploc; 169 176 #ifdef DEBUG 170 177 #if DEBUG == 2 … … 174 181 trputs("Shell args: "); trargs(argv); 175 182 #endif 176 rootpid = getpid();177 rootshell = 1;183 psh->rootpid = getpid(); 184 psh->rootshell = 1; 178 185 #ifdef _MSC_VER 179 186 { … … 187 194 if (argv[0] && argv[0][0] == '-') { 188 195 state = 1; 189 read_profile( "/etc/profile");196 read_profile(psh, "/etc/profile"); 190 197 state1: 191 198 state = 2; 192 read_profile( ".profile");199 read_profile(psh, ".profile"); 193 200 } 194 201 state2: 195 202 state = 3; 196 203 if (getuid() == geteuid() && getgid() == getegid()) { 197 if ((shinit = lookupvar( "ENV")) != NULL && *shinit != '\0') {204 if ((shinit = lookupvar(psh, "ENV")) != NULL && *shinit != '\0') { 198 205 state = 3; 199 read_profile( shinit);206 read_profile(psh, shinit); 200 207 } 201 208 } … … 214 221 215 222 for (i = 0; i < SIGSSIZE; i++) 216 setsignal( sigs[i], 0);217 } 218 219 if ( minusc)220 evalstring( minusc, 0);221 222 if ( sflag || minusc == NULL) {223 setsignal(psh, sigs[i], 0); 224 } 225 226 if (psh->minusc) 227 evalstring(psh, psh->minusc, 0); 228 229 if (psh->sflag || minusc == NULL) { 223 230 state4: /* XXX ??? - why isn't this before the "if" statement */ 224 cmdloop(1); 225 } 226 #if PROFILE 227 monitor(0); 228 #endif 229 exitshell(exitstatus); 231 cmdloop(psh, 1); 232 } 233 exitshell(psh, psh->exitstatus); 230 234 /* NOTREACHED */ 231 235 }
Note:
See TracChangeset
for help on using the changeset viewer.