Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2002-01-07 19:47:12 +0300
committerChristopher Faylor <me@cgf.cx>2002-01-07 19:47:12 +0300
commit4a08cbfefba72068259316476bf0a3b55026ca1c (patch)
tree09115b25550e9605ed0d39622071bc3757b023cb
parent10dedaaa4c128cf40419e8a42418ed8a223b9a70 (diff)
* 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/ChangeLog6
-rw-r--r--winsup/cygwin/sigproc.cc21
2 files changed, 17 insertions, 10 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index de4e329c2..1c2187c0b 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 2e409820a..36b563e1c 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;
}