From 153095405753e66b122b1e2d21e5cfdfdcf09617 Mon Sep 17 00:00:00 2001 From: Yaroslav Tykhiy Date: Sat, 4 Oct 2003 14:42:03 +0000 Subject: [PATCH] Don't dump core from the time(1) process itself if the child process has exited on a signal whose default action is to dump core. --- usr.bin/time/time.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/usr.bin/time/time.c b/usr.bin/time/time.c index c7a248629a2..15f1cb766f2 100644 --- a/usr.bin/time/time.c +++ b/usr.bin/time/time.c @@ -73,6 +73,7 @@ main(int argc, char **argv) int pid; int aflag, ch, hflag, lflag, status, pflag; struct timeval before, after; + struct rlimit rl; struct rusage ru; FILE *out = stderr; char *ofn = NULL; @@ -214,8 +215,12 @@ main(int argc, char **argv) if (exitonsig) { if (signal(exitonsig, SIG_DFL) == SIG_ERR) perror("signal"); - else + else { + rl.rlim_max = rl.rlim_cur = 0; + if (setrlimit(RLIMIT_CORE, &rl) == -1) + warn("setrlimit"); kill(getpid(), exitonsig); + } } exit (WIFEXITED(status) ? WEXITSTATUS(status) : EXIT_FAILURE); }