VirtualBox

Changeset 57 in kBuild


Ignore:
Timestamp:
Nov 23, 2003 10:38:39 PM (21 years ago)
Author:
bird
Message:

Config & adjustments for OS/2 LIBC. dllshell.

Location:
trunk/src/gmake
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/src/gmake/dir.c

    r53 r57  
    11971197  gl->gl_closedir = ansi_free;
    11981198  gl->gl_stat = local_stat;
     1199#ifdef __EMX__ /* The FreeBSD implemenation actually uses gl_lstat!! */
     1200  gl->gl_lstat = local_stat;
     1201#endif
    11991202  /* We don't bother setting gl_lstat, since glob never calls it.
    12001203     The slot is only there for compatibility with 4.4 BSD.  */
  • TabularUnified trunk/src/gmake/function.c

    r53 r57  
    15001500  CLOSE_ON_EXEC(pipedes[0]);
    15011501  /* 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);
    15031503  if (pid < 0)
    15041504    perror_with_name (error_prefix, "spawn");
  • TabularUnified trunk/src/gmake/job.c

    r53 r57  
    3131#include <string.h>
    3232
     33#ifdef MAKE_DLLSHELL
     34#include <dlfcn.h>
     35#endif
     36
    3337/* Default shell to use.  */
    3438#ifdef WINDOWS32
     
    5559#elif defined (__EMX__)
    5660
    57 const char *default_shell = "/bin/sh";
     61char *default_shell = "sh.exe";
    5862int batch_mode_shell = 0;
    5963
     
    201205#ifdef VMS
    202206static void vmsWaitForChildren PARAMS ((int *));
     207#endif
     208#ifdef MAKE_DLLSHELL
     209static int spawn_command PARAMS ((char **argv, char **envp, struct child *child));
    203210#endif
    204211
     
    434441static unsigned int dead_children = 0;
    435442
    436 #ifndef __EMX__ /* Don't use SIGCHLD handler on OS/2. */
    437443RETSIGTYPE
    438444child_handler (int sig)
     
    446452    }
    447453
     454#ifdef __EMX__
     455  signal(SIGCHLD, SIG_DFL); /* The signal handler must called only once! ????*/
     456#endif
     457
    448458  DB (DB_JOBS, (_("Got a SIGCHLD; %u unreaped children.\n"), dead_children));
    449459}
    450 #endif  /* !__EMX__ */
    451460
    452461extern int shell_function_pid, shell_function_completed;
     
    489498      int child_failed;
    490499      int any_remote, any_local;
     500#ifdef MAKE_DLLSHELL
     501      struct child *dllshelled_child = 0;
     502#endif
    491503
    492504      if (err && block)
     
    523535          any_remote |= c->remote;
    524536          any_local |= ! c->remote;
     537#ifdef MAKE_DLLSHELL
     538          if (c->dllshell_done)
     539            dllshelled_child = c;
     540#endif
    525541          DB (DB_JOBS, (_("Live child 0x%08lx (%s) PID %ld %s\n"),
    526542                        (unsigned long int) c, c->file->name,
     
    549565        {
    550566          /* 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
    551575#if !defined(__MSDOS__) && !defined(_AMIGA) && !defined(WINDOWS32)
    552576          if (any_local)
     
    579603              coredump = WCOREDUMP (status);
    580604
    581 #ifdef __EMX__
     605#if 0 /*def __EMX__*/
    582606              /* the SIGCHLD handler must not be used on OS/2 because, unlike
    583607                 on UNIX systems, it had to call wait() itself.  Therefore
     
    899923
    900924#ifdef MAKE_JOBSERVER
    901 # ifdef __EMX__
    902 /* Never install the SIGCHLD handler for EMX!!! */
    903 #  define set_child_handler_action_flags(x)
    904 # else
    905925/* Set the child handler action flags to FLAGS.  */
    906926static void
     
    918938#endif
    919939}
    920 #endif  /* !__EMX__ */
    921940#endif
    922941
     
    12041223
    12051224      /* 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);
    12081227      if (child->pid < 0)
    12091228        {
     
    16451664        got_token = read (job_rfd, &token, 1);
    16461665        saved_errno = errno;
     1666#ifdef __EMX__
     1667        signal(SIGCHLD, SIG_DFL); /* The child handler must be turned off here. */
     1668#endif
    16471669        set_child_handler_action_flags (SA_RESTART);
    16481670
     
    23262348/* EMX: Start a child process. This function returns the new pid.  */
    23272349# 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
    23282357int
    2329 child_execute_job (int stdin_fd, int stdout_fd, char **argv, char **envp)
     2358child_execute_job (int stdin_fd, int stdout_fd, char **argv, char **envp,
     2359                   struct child *child)
    23302360{
    23312361  int pid;
     
    23602390    CLOSE_ON_EXEC (stdout_fd);
    23612391
     2392#ifdef MAKE_DLLSHELL
     2393  pid = spawn_command(argv, envp, child);
     2394#else
    23622395  /* Run the command.  */
    23632396  pid = exec_command (argv, envp);
     2397#endif
    23642398
    23652399  /* Restore stdout/stdin of the parent process.  */
     
    23682402  if (stdout_fd != 1 && dup2 (save_stdout, 1) != 1)
    23692403    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);
    23702410
    23712411  return pid;
     
    23962436#endif /* !VMS */
    23972437#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. */
     2443static 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 */
    23982531
    23992532
  • TabularUnified trunk/src/gmake/job.h

    r53 r57  
    5858#endif
    5959    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
    6066    unsigned int remote:1;      /* Nonzero if executing remotely.  */
    6167
     
    7581#ifdef VMS
    7682extern 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)
     84extern int child_execute_job PARAMS ((int stdin_fd, int stdout_fd, char **argv, char **envp, struct child *child));
    7985#else
    8086extern void child_execute_job PARAMS ((int stdin_fd, int stdout_fd, char **argv, char **envp));
  • TabularUnified trunk/src/gmake/main.c

    r53 r57  
    19161916            int pid;
    19171917            int status;
    1918             pid = child_execute_job(0, 1, nargv, environ);
     1918            pid = child_execute_job(0, 1, nargv, environ, NULL);
    19191919
    19201920            /* is this loop really necessary? */
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette