Hi,
I have a weird test case (attached) where SIGCHLD is not being
received by libev. I don't quite understand if it's a
1) bug in how I use libev
2) bug in libev itself
3) bug in the OS
The work around I found that makes this test pass is to patch libev to
start a timer (active only when there are active child watchers) which
calls childcb periodically.
I tested it against the latest libev from CVS.
uname -a: Linux denis-laptop 3.2.0-23-generic-pae #36-Ubuntu SMP Tue
Apr 10 22:19:09 UTC 2012 i686 athlon i386 GNU/Linux
Cheers,
Denis.
/* gcc -DEV_STANDALONE=1 testsigchld.c -o testsigchld
*
* Expected output: infinite sequence of *.*.*.......
*
* Actual output:
* denis@denis-laptop:~/work/libev-cvs$ ./testsigchld
* *.*.*.Alarm clock
*
* (number of iterations is different each time)
*
* */
#include "ev.c"
struct ev_child child;
void stop_child(struct ev_loop* loop, ev_child *w, int revents) {
ev_child_stop(loop, w);
}
void stop_io(struct ev_loop* loop, ev_io *w, int revents) {
ev_io_stop(loop, w);
}
void subprocess(void) {
int pid;
ev_default_loop(0);
if (pid = fork()) {
ev_child_init(&child, stop_child, pid, 0);
ev_child_start(ev_default_loop(0), &child);
ev_run(ev_default_loop(0), 0);
fprintf(stderr, "*");
}
else {
_exit(0);
}
}
void test_main(void) {
int pipefd[2];
while (pipe(pipefd)) perror("pipe");
int pid = fork();
if (!pid) {
close(pipefd[0]);
subprocess();
write(pipefd[1], "k", 1);
_exit(0);
}
close(pipefd[1]);
alarm(5);
struct ev_io io;
ev_io_init(&io, stop_io, pipefd[0], 1);
ev_io_start(ev_default_loop(0), &io);
ev_run(ev_default_loop(0), 0);
alarm(0);
}
int main(int argc, char** argv) {
while (1) {
test_main();
fprintf(stderr, ".");
}
}
_______________________________________________
libev mailing list
[email protected]
http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev