diff options
Diffstat (limited to 'regress/lib/libc/longjmp/longjmp.c')
-rw-r--r-- | regress/lib/libc/longjmp/longjmp.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/regress/lib/libc/longjmp/longjmp.c b/regress/lib/libc/longjmp/longjmp.c new file mode 100644 index 00000000000..d8b9fe86bd6 --- /dev/null +++ b/regress/lib/libc/longjmp/longjmp.c @@ -0,0 +1,36 @@ +/* $OpenBSD: longjmp.c,v 1.1 2002/01/04 13:02:57 art Exp $ */ +/* + * Artur Grabowski <art@openbsd.org> Public Domain. + */ + +#include <setjmp.h> +#include <err.h> +#include <sys/types.h> +#include <sys/time.h> +#include <sys/resource.h> + + +jmp_buf buf; + +/* + * When longjmp is passed the incorrect arg (0), it should translate it into + * something better. + * + * Test is simple. rlimit the cpu time and throw an incorrect longjmp. If 0 + * is not translated we'll spin until we hit the cpu time limit. + */ +int +main() +{ + struct rlimit rl; + + rl.rlim_cur = 2; + rl.rlim_max = 2; + if (setrlimit(RLIMIT_CPU, &rl) < 0) + err(1, "setrlimit"); + + if (setjmp(buf) == 0) + longjmp(buf, 0); + + return 0; +} |