Check waitpid is not interrupted by a signal
Checks that the waitpid() call isn't interrupted by a signal when the handler for the signal is set to not interrupt the call
This commit is contained in:
parent
93dfc1839e
commit
ad5916c5e4
@ -231,6 +231,33 @@ START_TEST(test_g_signal_usr1)
|
|||||||
g_signal_usr1(NULL);
|
g_signal_usr1(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
START_TEST(test_waitpid_not_interrupted_by_sig)
|
||||||
|
{
|
||||||
|
/* Start a child which waits 3 seconds and exits */
|
||||||
|
int child_pid = g_fork();
|
||||||
|
if (child_pid == 0)
|
||||||
|
{
|
||||||
|
g_sleep(3000);
|
||||||
|
g_exit(42);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set an alarm for 1 second's time */
|
||||||
|
g_reset_wait_obj(g_wobj1);
|
||||||
|
g_set_alarm(set_wobj1, 1);
|
||||||
|
|
||||||
|
struct exit_status e = g_waitpid_status(child_pid);
|
||||||
|
// We should have had the alarm...
|
||||||
|
ck_assert_int_ne(g_is_wait_obj_set(g_wobj1), 0);
|
||||||
|
|
||||||
|
// ..and got the status of the child
|
||||||
|
ck_assert_int_eq(e.reason, E_XR_STATUS_CODE);
|
||||||
|
ck_assert_int_eq(e.val, 42);
|
||||||
|
|
||||||
|
// Clean up
|
||||||
|
g_set_alarm(NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
TCase *
|
TCase *
|
||||||
make_tcase_test_os_calls_signals(void)
|
make_tcase_test_os_calls_signals(void)
|
||||||
@ -246,6 +273,7 @@ make_tcase_test_os_calls_signals(void)
|
|||||||
tcase_add_test(tc, test_g_signal_terminate);
|
tcase_add_test(tc, test_g_signal_terminate);
|
||||||
tcase_add_test(tc, test_g_signal_pipe);
|
tcase_add_test(tc, test_g_signal_pipe);
|
||||||
tcase_add_test(tc, test_g_signal_usr1);
|
tcase_add_test(tc, test_g_signal_usr1);
|
||||||
|
tcase_add_test(tc, test_waitpid_not_interrupted_by_sig);
|
||||||
|
|
||||||
return tc;
|
return tc;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user