Page MenuHomeFreeBSD

D35187.id105915.diff
No OneTemporary

D35187.id105915.diff

Index: contrib/netbsd-tests/kernel/t_sysv.c
===================================================================
--- contrib/netbsd-tests/kernel/t_sysv.c
+++ contrib/netbsd-tests/kernel/t_sysv.c
@@ -54,11 +54,9 @@
#include <sys/shm.h>
#include <sys/wait.h>
-volatile int did_sigsys, did_sigchild;
-volatile int child_status, child_count;
+volatile int did_sigsys;
void sigsys_handler(int);
-void sigchld_handler(int);
key_t get_ftok(int);
@@ -142,23 +140,6 @@
did_sigsys = 1;
}
-void
-sigchld_handler(int signo)
-{
- int c_status;
-
- did_sigchild = 1;
- /*
- * Reap the child and return its status
- */
- if (wait(&c_status) == -1)
- child_status = -errno;
- else
- child_status = c_status;
-
- child_count--;
-}
-
key_t get_ftok(int id)
{
int fd;
@@ -205,13 +186,10 @@
struct sigaction sa;
struct msqid_ds m_ds;
struct testmsg m;
- sigset_t sigmask;
int sender_msqid;
int loop;
int c_status;
-
- if (atf_tc_get_config_var_as_bool_wd(tc, "ci", false))
- atf_tc_skip("https://bugs.freebsd.org/233649");
+ pid_t wait_result;
/*
* Install a SIGSYS handler so that we can exit gracefully if
@@ -224,18 +202,6 @@
ATF_REQUIRE_MSG(sigaction(SIGSYS, &sa, NULL) != -1,
"sigaction SIGSYS: %d", errno);
- /*
- * Install a SIGCHLD handler to deal with all possible exit
- * conditions of the receiver.
- */
- did_sigchild = 0;
- child_count = 0;
- sa.sa_handler = sigchld_handler;
- sigemptyset(&sa.sa_mask);
- sa.sa_flags = 0;
- ATF_REQUIRE_MSG(sigaction(SIGCHLD, &sa, NULL) != -1,
- "sigaction SIGCHLD: %d", errno);
-
msgkey = get_ftok(4160);
ATF_REQUIRE_MSG(msgkey != (key_t)-1, "get_ftok failed");
@@ -274,7 +240,6 @@
return;
case 0:
- child_count++;
receiver();
break;
@@ -313,29 +278,19 @@
/*
* Wait for child to finish
*/
- sigemptyset(&sigmask);
- (void) sigsuspend(&sigmask);
-
- /*
- * ...and any other signal is an unexpected error.
- */
- if (did_sigchild) {
- c_status = child_status;
- if (c_status < 0)
- atf_tc_fail("waitpid: %d", -c_status);
- else if (WIFEXITED(c_status) == 0)
- atf_tc_fail("child abnormal exit: %d", c_status);
- else if (WEXITSTATUS(c_status) != 0)
- atf_tc_fail("c status: %d", WEXITSTATUS(c_status));
- else {
- ATF_REQUIRE_MSG(msgctl(sender_msqid, IPC_STAT, &m_ds)
- != -1, "msgctl IPC_STAT: %d", errno);
+ wait_result = wait(&c_status);
+ if (wait_result < 0)
+ atf_tc_fail("wait: %d", errno);
+ else if (WIFEXITED(c_status) == 0)
+ atf_tc_fail("child abnormal exit: %d", c_status);
+ else if (WEXITSTATUS(c_status) != 0)
+ atf_tc_fail("c status: %d", WEXITSTATUS(c_status));
+ else {
+ ATF_REQUIRE_MSG(msgctl(sender_msqid, IPC_STAT, &m_ds)
+ != -1, "msgctl IPC_STAT: %d", errno);
- print_msqid_ds(&m_ds, 0600);
- atf_tc_pass();
- }
- } else
- atf_tc_fail("sender: received unexpected signal");
+ print_msqid_ds(&m_ds, 0600);
+ }
}
ATF_TC_CLEANUP(msg, tc)
@@ -445,10 +400,11 @@
struct sigaction sa;
union semun sun;
struct semid_ds s_ds;
- sigset_t sigmask;
int sender_semid;
int i;
int c_status;
+ int child_count;
+ pid_t wait_result;
/*
* Install a SIGSYS handler so that we can exit gracefully if
@@ -461,18 +417,6 @@
ATF_REQUIRE_MSG(sigaction(SIGSYS, &sa, NULL) != -1,
"sigaction SIGSYS: %d", errno);
- /*
- * Install a SIGCHLD handler to deal with all possible exit
- * conditions of the receiver.
- */
- did_sigchild = 0;
- child_count = 0;
- sa.sa_handler = sigchld_handler;
- sigemptyset(&sa.sa_mask);
- sa.sa_flags = 0;
- ATF_REQUIRE_MSG(sigaction(SIGCHLD, &sa, NULL) != -1,
- "sigaction SIGCHLD: %d", errno);
-
semkey = get_ftok(4160);
ATF_REQUIRE_MSG(semkey != (key_t)-1, "get_ftok failed");
@@ -546,33 +490,22 @@
/*
* Wait for all children to finish
*/
- sigemptyset(&sigmask);
- for (;;) {
- (void) sigsuspend(&sigmask);
- if (did_sigchild) {
- c_status = child_status;
- if (c_status < 0)
- atf_tc_fail("waitpid: %d", -c_status);
- else if (WIFEXITED(c_status) == 0)
- atf_tc_fail("c abnormal exit: %d", c_status);
- else if (WEXITSTATUS(c_status) != 0)
- atf_tc_fail("c status: %d",
- WEXITSTATUS(c_status));
- else {
- sun.buf = &s_ds;
- ATF_REQUIRE_MSG(semctl(sender_semid, 0,
- IPC_STAT, sun) != -1,
- "semctl IPC_STAT: %d", errno);
-
- print_semid_ds(&s_ds, 0600);
- atf_tc_pass();
- }
- if (child_count <= 0)
- break;
- did_sigchild = 0;
- } else {
- atf_tc_fail("sender: received unexpected signal");
- break;
+ while (child_count-- > 0) {
+ wait_result = wait(&c_status);
+ if (wait_result < 0)
+ atf_tc_fail("wait: %d", errno);
+ else if (WIFEXITED(c_status) == 0)
+ atf_tc_fail("c abnormal exit: %d", c_status);
+ else if (WEXITSTATUS(c_status) != 0)
+ atf_tc_fail("c status: %d",
+ WEXITSTATUS(c_status));
+ else {
+ sun.buf = &s_ds;
+ ATF_REQUIRE_MSG(semctl(sender_semid, 0,
+ IPC_STAT, sun) != -1,
+ "semctl IPC_STAT: %d", errno);
+
+ print_semid_ds(&s_ds, 0600);
}
}
}
@@ -640,7 +573,7 @@
err(1, "waiter: semop -1");
printf("WOO! GOT THE SEMAPHORE!\n");
- sleep(1);
+ usleep(10000);
/*
* Release the semaphore and exit.
@@ -671,10 +604,10 @@
{
struct sigaction sa;
struct shmid_ds s_ds;
- sigset_t sigmask;
char *shm_buf;
int sender_shmid;
int c_status;
+ pid_t wait_result;
/*
* Install a SIGSYS handler so that we can exit gracefully if
@@ -687,18 +620,6 @@
ATF_REQUIRE_MSG(sigaction(SIGSYS, &sa, NULL) != -1,
"sigaction SIGSYS: %d", errno);
- /*
- * Install a SIGCHLD handler to deal with all possible exit
- * conditions of the sharer.
- */
- did_sigchild = 0;
- child_count = 0;
- sa.sa_handler = sigchld_handler;
- sigemptyset(&sa.sa_mask);
- sa.sa_flags = 0;
- ATF_REQUIRE_MSG(sigaction(SIGCHLD, &sa, NULL) != -1,
- "sigaction SIGCHLD: %d", errno);
-
pgsize = sysconf(_SC_PAGESIZE);
shmkey = get_ftok(4160);
@@ -753,27 +674,20 @@
/*
* Wait for child to finish
*/
- sigemptyset(&sigmask);
- (void) sigsuspend(&sigmask);
-
- if (did_sigchild) {
- c_status = child_status;
- if (c_status < 0)
- atf_tc_fail("waitpid: %d", -c_status);
- else if (WIFEXITED(c_status) == 0)
- atf_tc_fail("c abnormal exit: %d", c_status);
- else if (WEXITSTATUS(c_status) != 0)
- atf_tc_fail("c status: %d", WEXITSTATUS(c_status));
- else {
- ATF_REQUIRE_MSG(shmctl(sender_shmid, IPC_STAT,
- &s_ds) != -1,
- "shmctl IPC_STAT: %d", errno);
+ wait_result = wait(&c_status);
+ if (wait_result < 0)
+ atf_tc_fail("wait: %d", errno);
+ else if (WIFEXITED(c_status) == 0)
+ atf_tc_fail("c abnormal exit: %d", c_status);
+ else if (WEXITSTATUS(c_status) != 0)
+ atf_tc_fail("c status: %d", WEXITSTATUS(c_status));
+ else {
+ ATF_REQUIRE_MSG(shmctl(sender_shmid, IPC_STAT,
+ &s_ds) != -1,
+ "shmctl IPC_STAT: %d", errno);
- print_shmid_ds(&s_ds, 0600);
- atf_tc_pass();
- }
- } else
- atf_tc_fail("sender: received unexpected signal");
+ print_shmid_ds(&s_ds, 0600);
+ }
}
static void

File Metadata

Mime Type
text/plain
Expires
Thu, Apr 9, 8:38 PM (5 h, 32 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31164249
Default Alt Text
D35187.id105915.diff (6 KB)

Event Timeline