summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2016-04-09 13:32:42 +0000
committerjilles <jilles@FreeBSD.org>2016-04-09 13:32:42 +0000
commit15cca94824de0fbecb8dc3951d0a7e27f5a0ec67 (patch)
treebf032f976c283c35de30d920650828c88cf09e0e /tools
parent336b1f7bb670aa4ebb365bab9cfc602548954333 (diff)
downloadFreeBSD-src-15cca94824de0fbecb8dc3951d0a7e27f5a0ec67.zip
FreeBSD-src-15cca94824de0fbecb8dc3951d0a7e27f5a0ec67.tar.gz
MFC r295385: semget(): Check for [EEXIST] error first.
Although POSIX literally permits failing with [EINVAL] if IPC_CREAT and IPC_EXCL were both passed, the semaphore set already exists and has fewer semaphores than nsems, this does not allow an application to retry safely: if the [EINVAL] is actually because of the semmsl limit, an infinite loop would result. PR: 206927
Diffstat (limited to 'tools')
-rw-r--r--tools/regression/sysvsem/semtest.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/tools/regression/sysvsem/semtest.c b/tools/regression/sysvsem/semtest.c
index 8a997d0..39c4164 100644
--- a/tools/regression/sysvsem/semtest.c
+++ b/tools/regression/sysvsem/semtest.c
@@ -152,6 +152,15 @@ main(int argc, char *argv[])
print_semid_ds(&s_ds, 0600);
+ errno = 0;
+ if (semget(semkey, 1, IPC_CREAT | IPC_EXCL | 0600) != -1 ||
+ errno != EEXIST)
+ err(1, "semget IPC_EXCL 1 did not fail with [EEXIST]");
+ errno = 0;
+ if (semget(semkey, 2, IPC_CREAT | IPC_EXCL | 0600) != -1 ||
+ errno != EEXIST)
+ err(1, "semget IPC_EXCL 2 did not fail with [EEXIST]");
+
for (child_count = 0; child_count < 5; child_count++) {
switch ((child_pid = fork())) {
case -1:
OpenPOWER on IntegriCloud