summaryrefslogtreecommitdiff
path: root/ccan/io/test/run-13-all-idle.c
blob: 7896b14f4e036913f2ae67feca4f3903e580b024 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <ccan/io/io.h>
/* Include the C files directly. */
#include <ccan/io/poll.c>
#include <ccan/io/io.c>
#include <ccan/tap/tap.h>
#include <sys/wait.h>
#include <stdio.h>
#include <signal.h>

static struct io_plan *setup_waiter(struct io_conn *conn, int *status)
{
	return io_wait(conn, status, io_close_cb, NULL);
}

int main(void)
{
	int status;

	plan_tests(3);

	if (fork() == 0) {
		int fds[2];

		ok1(pipe(fds) == 0);
		io_new_conn(NULL, fds[0], setup_waiter, &status);
		io_loop(NULL, NULL);
		exit(1);
	}

	ok1(wait(&status) != -1);
	ok1(WIFSIGNALED(status));
	ok1(WTERMSIG(status) == SIGABRT);

	/* This exits depending on whether all tests passed */
	return exit_status();
}