diff options
author | Christopher Faylor <me@cgf.cx> | 2002-01-07 16:47:12 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2002-01-07 16:47:12 +0000 |
commit | 4a08cbfefba72068259316476bf0a3b55026ca1c (patch) | |
tree | 09115b25550e9605ed0d39622071bc3757b023cb | |
parent | 10dedaaa4c128cf40419e8a42418ed8a223b9a70 (diff) | |
download | newlib-4a08cbfefba72068259316476bf0a3b55026ca1c.zip newlib-4a08cbfefba72068259316476bf0a3b55026ca1c.tar.gz newlib-4a08cbfefba72068259316476bf0a3b55026ca1c.tar.bz2 |
* sigproc.cc (getsem): Set errno when unable to create own semaphore.
Reorganize to make clearer that error should only come from initial creation of
process semaphore.
-rw-r--r-- | winsup/cygwin/ChangeLog | 6 | ||||
-rw-r--r-- | winsup/cygwin/sigproc.cc | 21 |
2 files changed, 17 insertions, 10 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index de4e329..1c2187c 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +2002-01-07 Christopher Faylor <cgf@redhat.com> + + * sigproc.cc (getsem): Set errno when unable to create own semaphore. + Reorganize to make clearer that error should only come from initial + creation of process semaphore. + 2002-01-06 Christopher Faylor <cgf@redhat.com> * dtable.cc (dtable::init_std_file_from_handle): Add some defensive diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index 2e40982..36b563e 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -926,6 +926,7 @@ getsem (_pinfo *p, const char *str, int init, int max) return NULL; } int wait = 1000; + /* Wait for new process to generate its semaphores. */ sigproc_printf ("pid %d, ppid %d, wait %d, initializing %x", p->pid, p->ppid, wait, ISSTATE (p, PID_INITIALIZING)); for (int i = 0; ISSTATE (p, PID_INITIALIZING) && i < wait; i++) @@ -941,27 +942,27 @@ getsem (_pinfo *p, const char *str, int init, int max) h = CreateSemaphore (allow_ntsec ? sec_user_nih (sa_buf) : &sec_none_nih, init, max, str = shared_name (str, winpid)); p = myself; + if (!h) + { + system_printf ("can't %s %s, %E", p ? "open" : "create", str); + __seterrno (); + } } else { h = OpenSemaphore (SEMAPHORE_ALL_ACCESS, FALSE, - str = shared_name (str, p->dwProcessId)); + shared_name (str, p->dwProcessId)); - if (h == NULL) + if (!h) { if (GetLastError () == ERROR_FILE_NOT_FOUND && !proc_exists (p)) - set_errno (ESRCH); + set_errno (ESRCH); /* No such process */ else - set_errno (EPERM); - return NULL; + set_errno (EPERM); /* Couldn't access the semaphore -- + different cygwin DLL maybe? */ } } - if (!h) - { - system_printf ("can't %s %s, %E", p ? "open" : "create", str); - set_errno (ESRCH); - } return h; } |