/******************************************************************************/ /** *Sendsanumberofsignalstotheprocessandcheckstheyarealldelivered * *@paramsigSignalnumber *@paramcountNumberofsignalstosend * *Thecallerisexpectedtoestablishasignalhandlerbeforethiscall
* which sets the global g_wobj1 on signal delivery */
static void send_multiple_signals(int sig, unsignedint count)
{ while (count-- > 0)
{
g_reset_wait_obj(g_wobj1);
ck_assert_int_eq(g_is_wait_obj_set(g_wobj1), 0); // Expect the signal to be delivered synchronously
raise(sig);
ck_assert_int_ne(g_is_wait_obj_set(g_wobj1), 0);
}
}
// Try another one to make sure the signal handler is still in place. // This one can generate a signal
g_reset_wait_obj(g_wobj1);
pid = g_fork(); if (pid == 0)
{ // Before raising the signal, change directory to a non-writeable // one to avoid generating a corefile.
g_set_current_dir("/");
raise(SIGSEGV);
}
ck_assert_int_ne(pid, 0);
g_obj_wait(&g_wobj1, 1, NULL, 0, 2000);
ck_assert_int_ne(g_is_wait_obj_set(g_wobj1), 0);
/******************************************************************************/ /* Checks that multiple children finishing do not interrupt
* g_waitpid_status() */
START_TEST(test_g_signal_child_stop_2)
{ #define CHILD_COUNT 20 int pids[CHILD_COUNT]; unsignedint i;
// Only one signal can be received in this way. After handling // the signal the handler should be automatically reset.
send_multiple_signals(SIGSEGV, 1);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.