Changeset 3156 for trunk/src/kmk/job.c


Ignore:
Timestamp:
Mar 18, 2018, 9:10:03 PM (7 years ago)
Author:
bird
Message:

kmk/win: Reworking child process handling. This effort will hopefully handle processor groups better and allow executing internal function off the main thread.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/job.c

    r3141 r3156  
    117117# include <io.h>
    118118# include <process.h>
    119 # include "sub_proc.h"
     119# ifdef CONFIG_NEW_WIN_CHILDREN
     120#  include "w32/winchildren.h"
     121# else
     122#  include "sub_proc.h"
     123# endif
    120124# include "w32err.h"
    121125# include "pathstuff.h"
     
    262266
    263267#ifdef WINDOWS32
     268# ifndef CONFIG_NEW_WIN_CHILDREN /* (only used by commands.c) */
    264269/*
    265270 * The macro which references this function is defined in makeint.h.
     
    270275  return ((process_kill ((HANDLE)pid, sig) == TRUE) ? 0 : -1);
    271276}
     277# endif /* !CONFIG_NEW_WIN_CHILDREN */
    272278
    273279/* This function creates a temporary file name with an extension specified
     
    807813#endif /* _AMIGA */
    808814#ifdef WINDOWS32
     815# ifndef CONFIG_NEW_WIN_CHILDREN
    809816          {
    810817            HANDLE hPID;
     
    869876            pid = (pid_t) hPID;
    870877          }
     878# else  /* CONFIG_NEW_WIN_CHILDREN */
     879          assert (!any_remote);
     880          pid = 0;
     881          coredump = exit_sig = exit_code = 0;
     882          {
     883            int rc = MkWinChildWait(block, &pid, &exit_code, &exit_sig, &coredump, &c);
     884            if (rc != 0)
     885                  ON (fatal, NILF, _("MkWinChildWait: %u"), rc);
     886          }
     887          if (pid == 0)
     888            {
     889              /* No more children, stop. */
     890              reap_more = 0;
     891              break;
     892            }
     893
     894          /* If we have started jobs in this second, remove one.  */
     895          if (job_counter)
     896            --job_counter;
     897# endif /* CONFIG_NEW_WIN_CHILDREN */
    871898#endif /* WINDOWS32 */
    872899        }
     
    16561683#ifdef WINDOWS32
    16571684  {
     1685#  ifndef CONFIG_NEW_WIN_CHILDREN
    16581686      HANDLE hPID;
    16591687      char* arg0;
     
    16991727          goto error;
    17001728        }
     1729#  else   /* CONFIG_NEW_WIN_CHILDREN */
     1730    struct variable *shell_var = lookup_variable("SHELL", 5);
     1731    const char *shell_value = !shell_var ? NULL
     1732                            : !shell_var->recursive || strchr(shell_var->value, '$') == NULL
     1733                            ? shell_var->value : variable_expand (shell_var->value);
     1734    int rc = MkWinChildCreate(argv, child->environment, shell_value, child, &child->pid);
     1735    if (rc != 0)
     1736      {
     1737        int i;
     1738        unblock_sigs ();
     1739        fprintf (stderr, _("failed to launch process (rc=%d)\n"), rc);
     1740        for (i = 0; argv[i]; i++)
     1741          fprintf (stderr, "%s ", argv[i]);
     1742        fprintf (stderr, "\n", argv[i]);
     1743        goto error;
     1744      }
     1745#endif  /* CONFIG_NEW_WIN_CHILDREN */
    17011746  }
    17021747#endif /* WINDOWS32 */
     
    17711816#endif
    17721817#ifdef WINDOWS32
     1818# ifndef CONFIG_NEW_WIN_CHILDREN
    17731819          || (process_used_slots () >= MAXIMUM_WAIT_OBJECTS)
     1820# endif
    17741821#endif
    17751822          ))
     
    21932240  time_t now;
    21942241
    2195 #ifdef WINDOWS32
     2242#if defined(WINDOWS32) && !defined(CONFIG_NEW_WIN_CHILDREN)
    21962243  /* sub_proc.c cannot wait for more than MAXIMUM_WAIT_OBJECTS children */
    21972244  if (process_used_slots () >= MAXIMUM_WAIT_OBJECTS)
     
    24362483
    24372484
     2485#if !defined(WINDOWS32) || !defined(CONFIG_NEW_WIN_CHILDREN)
    24382486#ifndef _AMIGA
    24392487/* Replace the current process with one running the command in ARGV,
     
    24592507#else
    24602508#ifdef WINDOWS32
     2509# ifndef CONFIG_NEW_WIN_CHILDREN
    24612510  HANDLE hPID;
    24622511  HANDLE hWaitPID;
     
    25142563  /* return child's exit code as our exit code */
    25152564  exit (exit_code);
    2516 
     2565# else  /* CONFIG_NEW_WIN_CHILDREN */
     2566
     2567# endif /* CONFIG_NEW_WIN_CHILDREN */
    25172568#else  /* !WINDOWS32 */
    25182569
     
    26482699
    26492700#endif /* On Amiga */
     2701#endif /* !defined(WINDOWS32) || !defined(CONFIG_NEW_WIN_CHILDREN) */
    26502702
    26512703
     
    27772829
    27782830  const char *sh_chars;
    2779   const char **sh_cmds;
     2831  char const * const * sh_cmds;                                                /* kmk: +_sh +const*2 */
    27802832#elif defined(__riscos__)
    27812833  static const char *sh_chars = "";
     
    33303382                /* This is the start of a new recipe line.  Skip whitespace
    33313383                   and prefix characters but not newlines.  */
     3384#ifndef CONFIG_WITH_COMMANDS_FUNC
    33323385                while (ISBLANK (*f) || *f == '-' || *f == '@' || *f == '+')
     3386#else
     3387                char ch;
     3388                while (ISBLANK ((ch = *f)) || ch == '-' || ch == '@' || ch == '+' || ch == '%')
     3389#endif
    33333390                  ++f;
    33343391
     
    33823439                /* This is the start of a new recipe line.  Skip whitespace
    33833440                   and prefix characters but not newlines.  */
     3441#ifndef CONFIG_WITH_COMMANDS_FUNC
    33843442                while (ISBLANK (*f) || *f == '-' || *f == '@' || *f == '+')
     3443#else
     3444                char ch;
     3445                while (ISBLANK ((ch = *f)) || ch == '-' || ch == '@' || ch == '+' || ch == '%')
     3446#endif
    33853447                  ++f;
    33863448
Note: See TracChangeset for help on using the changeset viewer.