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


Ignore:
Timestamp:
Mar 19, 2018, 2:37:13 PM (7 years ago)
Author:
bird
Message:

kmk/win: Some fixes & docs.

File:
1 edited

Legend:

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

    r3156 r3159  
    4242int no_default_sh_exe = 1;
    4343int batch_mode_shell = 1;
     44# ifndef CONFIG_NEW_WIN32_CTRL_EVENT
    4445HANDLE main_thread;
     46# endif
    4547
    4648#elif defined (_AMIGA)
     
    813815#endif /* _AMIGA */
    814816#ifdef WINDOWS32
     817          {
    815818# ifndef CONFIG_NEW_WIN_CHILDREN
    816           {
    817819            HANDLE hPID;
    818820            HANDLE hcTID, hcPID;
     
    822824            coredump = 0;
    823825
     826#  ifndef CONFIG_NEW_WIN32_CTRL_EVENT
    824827            /* Record the thread ID of the main process, so that we
    825828               could suspend it in the signal handler.  */
     
    839842                  DB (DB_VERBOSE, ("Main thread handle = %p\n", main_thread));
    840843              }
     844#  endif
    841845
    842846            /* wait for anything to finish */
     
    875879
    876880            pid = (pid_t) hPID;
     881# else  /* CONFIG_NEW_WIN_CHILDREN */
     882#  ifndef CONFIG_NEW_WIN32_CTRL_EVENT
     883            /* Ctrl-C handler needs to suspend the main thread handle to
     884               prevent mayhem when concurrently calling reap_children.  */
     885            if (   !main_thread
     886                && !DuplicateHandle (GetCurrentProcess (), GetCurrentThread (),
     887                                     GetCurrentProcess (), &main_thread, 0,
     888                                     FALSE, DUPLICATE_SAME_ACCESS))
     889              fprintf (stderr, "Failed to duplicate main thread handle: %u\n",
     890                       GetLastError ());
     891#  endif
     892
     893            assert (!any_remote);
     894            pid = 0;
     895            coredump = exit_sig = exit_code = 0;
     896            {
     897              int rc = MkWinChildWait(block, &pid, &exit_code, &exit_sig, &coredump, &c);
     898              if (rc != 0)
     899                    ON (fatal, NILF, _("MkWinChildWait: %u"), rc);
     900            }
     901            if (pid == 0)
     902              {
     903                /* No more children, stop. */
     904                reap_more = 0;
     905                break;
     906              }
     907
     908            /* If we have started jobs in this second, remove one.  */
     909            if (job_counter)
     910              --job_counter;
     911# endif /* CONFIG_NEW_WIN_CHILDREN */
    877912          }
    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 */
    898913#endif /* WINDOWS32 */
    899914        }
Note: See TracChangeset for help on using the changeset viewer.