From 736a80db080275a91a3ba4311f79ef9e5e00e225 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 5 Feb 2018 14:39:27 +1030 Subject: [PATCH] ccan: update so ccan/io doesn't exit when we get signals. In particular, we're going to capture SIGUSR1. Signed-off-by: Rusty Russell --- ccan/README | 2 +- ccan/ccan/io/poll.c | 7 ++++++- ccan/ccan/opt/usage.c | 2 ++ ccan/ccan/tal/path/path.c | 2 +- ccan/ccan/tal/path/test/run-join.c | 7 ++++++- ccan/tools/configurator/configurator.c | 2 ++ 6 files changed, 18 insertions(+), 4 deletions(-) diff --git a/ccan/README b/ccan/README index 139fec08647c..d132d3213371 100644 --- a/ccan/README +++ b/ccan/README @@ -1,3 +1,3 @@ CCAN imported from http://ccodearchive.net. -CCAN version: init-2398-g7082f7d0 +CCAN version: init-2401-ge2d15a2b diff --git a/ccan/ccan/io/poll.c b/ccan/ccan/io/poll.c index 3354abe01a2b..b005a97e4b1d 100644 --- a/ccan/ccan/io/poll.c +++ b/ccan/ccan/io/poll.c @@ -280,8 +280,13 @@ void *io_loop(struct timers *timers, struct timer **expired) } r = pollfn(pollfds, num_fds, ms_timeout); - if (r < 0) + if (r < 0) { + /* Signals shouldn't break us, unless they set + * io_loop_return. */ + if (errno == EINTR) + continue; break; + } for (i = 0; i < num_fds && !io_loop_return; i++) { struct io_conn *c = (void *)fds[i]; diff --git a/ccan/ccan/opt/usage.c b/ccan/ccan/opt/usage.c index 26150ea8cd40..353d59bc4854 100644 --- a/ccan/ccan/opt/usage.c +++ b/ccan/ccan/opt/usage.c @@ -4,7 +4,9 @@ #include #include /* Required on Solaris for struct winsize */ #endif +#if HAVE_SYS_UNISTD_H #include /* Required on Solaris for ioctl */ +#endif #include #include #include diff --git a/ccan/ccan/tal/path/path.c b/ccan/ccan/tal/path/path.c index 362152d29cb2..c7a134e3c9d9 100644 --- a/ccan/ccan/tal/path/path.c +++ b/ccan/ccan/tal/path/path.c @@ -52,7 +52,7 @@ char *path_join(const tal_t *ctx, const char *base, const char *a) ret = tal_dup_arr(ctx, char, base, len, 1 + strlen(a) + 1); if (!ret) goto out; - if (ret[len-1] != PATH_SEP) + if (len != 0 && ret[len-1] != PATH_SEP) ret[len++] = PATH_SEP; strcpy(ret + len, a); diff --git a/ccan/ccan/tal/path/test/run-join.c b/ccan/ccan/tal/path/test/run-join.c index 3961cbb13240..05d3d6e1ea73 100644 --- a/ccan/ccan/tal/path/test/run-join.c +++ b/ccan/ccan/tal/path/test/run-join.c @@ -6,7 +6,7 @@ int main(void) { char *path, *ctx = tal_strdup(NULL, "ctx"); - plan_tests(34); + plan_tests(36); path = path_join(ctx, "foo", "bar"); ok1(streq(path, "foo/bar")); @@ -85,6 +85,11 @@ int main(void) ok1(!path); ok1(!tal_first(ctx)); + path = path_join(ctx, "", "bar"); + ok1(streq(path, "bar")); + ok1(tal_parent(path) == ctx); + tal_free(path); + tal_free(ctx); return exit_status(); diff --git a/ccan/tools/configurator/configurator.c b/ccan/tools/configurator/configurator.c index 6ec30bd6deb7..52c0243b4b99 100644 --- a/ccan/tools/configurator/configurator.c +++ b/ccan/tools/configurator/configurator.c @@ -315,6 +315,8 @@ static struct test tests[] = { "#include \n" }, { "HAVE_SYS_TERMIOS_H", OUTSIDE_MAIN, NULL, NULL, "#include \n" }, + { "HAVE_SYS_UNISTD_H", OUTSIDE_MAIN, NULL, NULL, + "#include \n" }, { "HAVE_TYPEOF", INSIDE_MAIN, NULL, NULL, "__typeof__(argc) i; i = argc; return i == argc ? 0 : 1;" }, { "HAVE_UNALIGNED_ACCESS", DEFINES_EVERYTHING|EXECUTE, NULL, NULL,