From 8daa83a594a2e98f39d764422bfbdbc62c9efd44 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 19:20:00 +0200 Subject: Adding upstream version 2:4.20.0+dfsg. Signed-off-by: Daniel Baumann --- third_party/heimdal/tests/bin/intr.c | 56 ++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 third_party/heimdal/tests/bin/intr.c (limited to 'third_party/heimdal/tests/bin/intr.c') diff --git a/third_party/heimdal/tests/bin/intr.c b/third_party/heimdal/tests/bin/intr.c new file mode 100644 index 0000000..867c5c2 --- /dev/null +++ b/third_party/heimdal/tests/bin/intr.c @@ -0,0 +1,56 @@ +#include + +#include +#include +#include + +static int help_flag; +static int timeout = 3; + +static struct getargs args[] = { + { "help", 'h', arg_flag, &help_flag, NULL, NULL }, + { "timeout", 't', arg_integer, &timeout, NULL, NULL } +}; + +static int nargs = sizeof(args) / sizeof(args[0]); + +static time_t +handle_timeout(void *data) +{ + static int killed; + + if (!killed++) + return -1; /* kill it */ + return -2; /* stop waiting for it */ +} + +static void +usage(int status) +{ + arg_printusage(args, nargs, NULL, "command"); + exit(status); +} + + +int +main(int argc, char **argv) +{ + int optidx = 0; + + setprogname(argv[0]); + + if (getarg(args, nargs, argc, argv, &optidx)) + usage(1); + + if (help_flag) + usage(0); + + argc -= optidx; + argv += optidx; + + if (argc == 0) + usage(1); + + return simple_execvp_timed(argv[0], argv, handle_timeout, NULL, + timeout); +} -- cgit v1.2.3