Changeset 57 in kBuild
- Timestamp:
- Nov 23, 2003 10:38:39 PM (21 years ago)
- Location:
- trunk/src/gmake
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/src/gmake/dir.c ¶
r53 r57 1197 1197 gl->gl_closedir = ansi_free; 1198 1198 gl->gl_stat = local_stat; 1199 #ifdef __EMX__ /* The FreeBSD implemenation actually uses gl_lstat!! */ 1200 gl->gl_lstat = local_stat; 1201 #endif 1199 1202 /* We don't bother setting gl_lstat, since glob never calls it. 1200 1203 The slot is only there for compatibility with 4.4 BSD. */ -
TabularUnified trunk/src/gmake/function.c ¶
r53 r57 1500 1500 CLOSE_ON_EXEC(pipedes[0]); 1501 1501 /* Never use fork()/exec() here! Use spawn() instead in exec_command() */ 1502 pid = child_execute_job (0, pipedes[1], command_argv, envp );1502 pid = child_execute_job (0, pipedes[1], command_argv, envp, NULL); 1503 1503 if (pid < 0) 1504 1504 perror_with_name (error_prefix, "spawn"); -
TabularUnified trunk/src/gmake/job.c ¶
r53 r57 31 31 #include <string.h> 32 32 33 #ifdef MAKE_DLLSHELL 34 #include <dlfcn.h> 35 #endif 36 33 37 /* Default shell to use. */ 34 38 #ifdef WINDOWS32 … … 55 59 #elif defined (__EMX__) 56 60 57 c onst char *default_shell = "/bin/sh";61 char *default_shell = "sh.exe"; 58 62 int batch_mode_shell = 0; 59 63 … … 201 205 #ifdef VMS 202 206 static void vmsWaitForChildren PARAMS ((int *)); 207 #endif 208 #ifdef MAKE_DLLSHELL 209 static int spawn_command PARAMS ((char **argv, char **envp, struct child *child)); 203 210 #endif 204 211 … … 434 441 static unsigned int dead_children = 0; 435 442 436 #ifndef __EMX__ /* Don't use SIGCHLD handler on OS/2. */437 443 RETSIGTYPE 438 444 child_handler (int sig) … … 446 452 } 447 453 454 #ifdef __EMX__ 455 signal(SIGCHLD, SIG_DFL); /* The signal handler must called only once! ????*/ 456 #endif 457 448 458 DB (DB_JOBS, (_("Got a SIGCHLD; %u unreaped children.\n"), dead_children)); 449 459 } 450 #endif /* !__EMX__ */451 460 452 461 extern int shell_function_pid, shell_function_completed; … … 489 498 int child_failed; 490 499 int any_remote, any_local; 500 #ifdef MAKE_DLLSHELL 501 struct child *dllshelled_child = 0; 502 #endif 491 503 492 504 if (err && block) … … 523 535 any_remote |= c->remote; 524 536 any_local |= ! c->remote; 537 #ifdef MAKE_DLLSHELL 538 if (c->dllshell_done) 539 dllshelled_child = c; 540 #endif 525 541 DB (DB_JOBS, (_("Live child 0x%08lx (%s) PID %ld %s\n"), 526 542 (unsigned long int) c, c->file->name, … … 549 565 { 550 566 /* No remote children. Check for local children. */ 567 #ifdef MAKE_DLLSHELL 568 if (dllshelled_child) 569 { 570 pid = dllshelled_child->pid; 571 status = (WAIT_T)dllshelled_child->status; 572 } 573 else 574 #endif 551 575 #if !defined(__MSDOS__) && !defined(_AMIGA) && !defined(WINDOWS32) 552 576 if (any_local) … … 579 603 coredump = WCOREDUMP (status); 580 604 581 #if def __EMX__605 #if 0 /*def __EMX__*/ 582 606 /* the SIGCHLD handler must not be used on OS/2 because, unlike 583 607 on UNIX systems, it had to call wait() itself. Therefore … … 899 923 900 924 #ifdef MAKE_JOBSERVER 901 # ifdef __EMX__902 /* Never install the SIGCHLD handler for EMX!!! */903 # define set_child_handler_action_flags(x)904 # else905 925 /* Set the child handler action flags to FLAGS. */ 906 926 static void … … 918 938 #endif 919 939 } 920 #endif /* !__EMX__ */921 940 #endif 922 941 … … 1204 1223 1205 1224 /* Never use fork()/exec() here! Use spawn() instead in exec_command() */ 1206 child ->pid = child_execute_job (child->good_stdin ? 0 : bad_stdin, 1,1207 argv, child->environment);1225 child_execute_job (child->good_stdin ? 0 : bad_stdin, 1, 1226 argv, child->environment, child); 1208 1227 if (child->pid < 0) 1209 1228 { … … 1645 1664 got_token = read (job_rfd, &token, 1); 1646 1665 saved_errno = errno; 1666 #ifdef __EMX__ 1667 signal(SIGCHLD, SIG_DFL); /* The child handler must be turned off here. */ 1668 #endif 1647 1669 set_child_handler_action_flags (SA_RESTART); 1648 1670 … … 2326 2348 /* EMX: Start a child process. This function returns the new pid. */ 2327 2349 # if defined __MSDOS__ || defined __EMX__ 2350 /* The child argument can be NULL (that's why we return the pid), if it is 2351 and the shell is a dllshell:// a child structure is created and inserted 2352 into the child list so reap_children can do its job. 2353 2354 BTW. the name of this function in this port is very misleading, spawn_job 2355 would perhaps be more appropriate. */ 2356 2328 2357 int 2329 child_execute_job (int stdin_fd, int stdout_fd, char **argv, char **envp) 2358 child_execute_job (int stdin_fd, int stdout_fd, char **argv, char **envp, 2359 struct child *child) 2330 2360 { 2331 2361 int pid; … … 2360 2390 CLOSE_ON_EXEC (stdout_fd); 2361 2391 2392 #ifdef MAKE_DLLSHELL 2393 pid = spawn_command(argv, envp, child); 2394 #else 2362 2395 /* Run the command. */ 2363 2396 pid = exec_command (argv, envp); 2397 #endif 2364 2398 2365 2399 /* Restore stdout/stdin of the parent process. */ … … 2368 2402 if (stdout_fd != 1 && dup2 (save_stdout, 1) != 1) 2369 2403 fatal (NILF, _("restoring of stdout failed\n")); 2404 2405 /* Cleanup handles */ 2406 if (stdin_fd != 0) 2407 close (save_stdin); 2408 if (stdout_fd != 1) 2409 close (save_stdout); 2370 2410 2371 2411 return pid; … … 2396 2436 #endif /* !VMS */ 2397 2437 #endif /* !WINDOWS32 */ 2438 2439 2440 #ifdef MAKE_DLLSHELL 2441 /* This is called when all pipes and such are configured for the 2442 child process. The child argument may be null, see child_execute_job. */ 2443 static int spawn_command (char **argv, char **envp, struct child *c) 2444 { 2445 /* Now let's see if there is a DLLSHELL specifier in the 2446 first argument. */ 2447 if (!strncmp(argv[0], "dllshell://", 11)) 2448 { 2449 static void *cur_dll; /* current loaded dll. */ 2450 static char *cur_dllspec; /* dllshell without shell arg. */ 2451 /* pointer to the entrypoint. */ 2452 static pid_t (*cur_spawn) PARAMS ((char **argv, char **envp, int *status, char *done)); 2453 2454 /* dllshell://<dllname>!<exec>[!<realshell>] */ 2455 char *name, *name_end, *symbol, *symbol_end; 2456 int len_basespec; 2457 int insert_child = 0; 2458 2459 /* parse it */ 2460 name = argv[0] + 11; 2461 name_end = strchr (name, '!'); 2462 if (!name_end) 2463 fatal (NILF, _("%s : malformed specifier!\n"), argv[0]); 2464 symbol = name_end + 1; 2465 symbol_end = strchr (symbol, '!'); 2466 if (symbol == symbol_end) 2467 fatal (NILF, _("%s : malformed specifier!\n"), argv[0]); 2468 if (symbol_end) 2469 symbol_end = strchr (symbol, 0); 2470 len_basespec = symbol_end - name; 2471 2472 /* need loading? */ 2473 if ( !cur_dllspec 2474 || strncmp (name, cur_dllspec, len_basespec) 2475 || argv[len_basespec]) 2476 { 2477 if (cur_dll) 2478 { 2479 dlclose (cur_dll); 2480 free (cur_dllspec); 2481 } 2482 cur_dllspec = strdup (name); 2483 cur_dllspec[len_basespec] = '\0'; 2484 cur_dllspec[name_end - name] = '\0'; 2485 cur_dll = dlopen (cur_dllspec, RTLD_LOCAL); 2486 if (!cur_dll) 2487 fatal (NILF, _("%s : failed to load! dlerror: '%s'\n"), argv[0], dlerror()); 2488 cur_dllspec[name_end - name] = '!'; 2489 cur_spawn = dlsym (cur_dll, cur_dllspec + (symbol - name)); 2490 if (!cur_spawn) 2491 fatal (NILF, _("%s : failed to find symbol! dlerror: %s\n"), argv[0], dlerror()); 2492 } 2493 2494 /* make child struct? */ 2495 if (!c) 2496 { 2497 c = (struct child *) xmalloc (sizeof (struct child)); 2498 bzero ((char *)c, sizeof (struct child)); 2499 insert_child = 1; 2500 } 2501 2502 /* call it. return value is 0 on succes, -1 on failure. */ 2503 c->pid = cur_spawn (argv, envp, &c->status, &c->dllshell_done); 2504 DB (DB_JOBS, (_("dllshell pid=%x"), c->pid)); 2505 2506 if (insert_child && c->pid > 0) 2507 { 2508 c->next = children; 2509 DB (DB_JOBS, (_("Putting child 0x%08lx (-) PID %ld on the chain.\n"), 2510 (unsigned long int) c, (long) c->pid)); 2511 children = c; 2512 /* One more job slot is in use. */ 2513 ++job_slots_used; 2514 } 2515 } 2516 else 2517 { 2518 /* Run the command. */ 2519 #ifdef __EMX__ 2520 c->pid = 2521 exec_command (argv, envp); 2522 #else 2523 # error MAKE_DLLSHELL is not ported to your platform yet. 2524 #endif 2525 DB (DB_JOBS, (_("spawn pid=%x"), c->pid)); 2526 } 2527 2528 return c->pid; 2529 } 2530 #endif /* MAKE_DLLSHELL */ 2398 2531 2399 2532 -
TabularUnified trunk/src/gmake/job.h ¶
r53 r57 58 58 #endif 59 59 char *sh_batch_file; /* Script file for shell commands */ 60 #ifdef MAKE_DLLSHELL 61 int status; /* Status of the job. 62 Another thread might set this. */ 63 char dllshell_done; /* Nonzero if executed thru a dll shell. 64 Another thread might set this. */ 65 #endif 60 66 unsigned int remote:1; /* Nonzero if executing remotely. */ 61 67 … … 75 81 #ifdef VMS 76 82 extern int child_execute_job PARAMS ((char *argv, struct child *child)); 77 #elif defined(__EMX__) 78 extern int child_execute_job PARAMS ((int stdin_fd, int stdout_fd, char **argv, char **envp ));83 #elif defined(__EMX__) || defined (MAKE_DLLSHELL) 84 extern int child_execute_job PARAMS ((int stdin_fd, int stdout_fd, char **argv, char **envp, struct child *child)); 79 85 #else 80 86 extern void child_execute_job PARAMS ((int stdin_fd, int stdout_fd, char **argv, char **envp)); -
TabularUnified trunk/src/gmake/main.c ¶
r53 r57 1916 1916 int pid; 1917 1917 int status; 1918 pid = child_execute_job(0, 1, nargv, environ );1918 pid = child_execute_job(0, 1, nargv, environ, NULL); 1919 1919 1920 1920 /* is this loop really necessary? */
Note:
See TracChangeset
for help on using the changeset viewer.