Index: sigproc.cc =================================================================== RCS file: /cvs/src/src/winsup/cygwin/sigproc.cc,v retrieving revision 1.95.2.2 diff -u -p -r1.95.2.2 sigproc.cc --- sigproc.cc 2002/01/04 03:56:10 1.95.2.2 +++ sigproc.cc 2002/01/07 14:03:20 @@ -930,38 +930,33 @@ getsem (_pinfo *p, const char *str, int ISSTATE (p, PID_INITIALIZING)); for (int i = 0; ISSTATE (p, PID_INITIALIZING) && i < wait; i++) Sleep (1); - } - - SetLastError (0); - if (p == NULL) - { - char sa_buf[1024]; - - DWORD winpid = GetCurrentProcessId (); - h = CreateSemaphore (allow_ntsec ? sec_user_nih (sa_buf) : &sec_none_nih, - init, max, str = shared_name (str, winpid)); - p = myself; - } - else - { + SetLastError (0); h = OpenSemaphore (SEMAPHORE_ALL_ACCESS, FALSE, - str = shared_name (str, p->dwProcessId)); + str = shared_name (str, p->dwProcessId)); if (h == NULL) - { + { if (GetLastError () == ERROR_FILE_NOT_FOUND && !proc_exists (p)) set_errno (ESRCH); else set_errno (EPERM); - return NULL; } } - - if (!h) + else { - system_printf ("can't %s %s, %E", p ? "open" : "create", str); - set_errno (ESRCH); + SetLastError (0); + char sa_buf[1024]; + + DWORD winpid = GetCurrentProcessId (); + h = CreateSemaphore (allow_ntsec ? sec_user_nih (sa_buf) : &sec_none_nih, + init, max, str = shared_name (str, winpid)); + p = myself; + if (h == NULL) + set_errno (ESRCH); } + + if (h == NULL) + system_printf ("can't %s %s, %E", p ? "open" : "create", str); return h; }