1bbeaf6c0SSean Eric Fagan /* 209d64da3SSean Eric Fagan * Copryight 1997 Sean Eric Fagan 309d64da3SSean Eric Fagan * 409d64da3SSean Eric Fagan * Redistribution and use in source and binary forms, with or without 509d64da3SSean Eric Fagan * modification, are permitted provided that the following conditions 609d64da3SSean Eric Fagan * are met: 709d64da3SSean Eric Fagan * 1. Redistributions of source code must retain the above copyright 809d64da3SSean Eric Fagan * notice, this list of conditions and the following disclaimer. 909d64da3SSean Eric Fagan * 2. Redistributions in binary form must reproduce the above copyright 1009d64da3SSean Eric Fagan * notice, this list of conditions and the following disclaimer in the 1109d64da3SSean Eric Fagan * documentation and/or other materials provided with the distribution. 1209d64da3SSean Eric Fagan * 3. All advertising materials mentioning features or use of this software 1309d64da3SSean Eric Fagan * must display the following acknowledgement: 1409d64da3SSean Eric Fagan * This product includes software developed by Sean Eric Fagan 1509d64da3SSean Eric Fagan * 4. Neither the name of the author may be used to endorse or promote 1609d64da3SSean Eric Fagan * products derived from this software without specific prior written 1709d64da3SSean Eric Fagan * permission. 1809d64da3SSean Eric Fagan * 1909d64da3SSean Eric Fagan * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 2009d64da3SSean Eric Fagan * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2109d64da3SSean Eric Fagan * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2209d64da3SSean Eric Fagan * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2309d64da3SSean Eric Fagan * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2409d64da3SSean Eric Fagan * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2509d64da3SSean Eric Fagan * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2609d64da3SSean Eric Fagan * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2709d64da3SSean Eric Fagan * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2809d64da3SSean Eric Fagan * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2909d64da3SSean Eric Fagan * SUCH DAMAGE. 3009d64da3SSean Eric Fagan */ 3109d64da3SSean Eric Fagan 32b956c13cSPhilippe Charnier #include <sys/cdefs.h> 33b956c13cSPhilippe Charnier __FBSDID("$FreeBSD$"); 343cf51049SPhilippe Charnier 3509d64da3SSean Eric Fagan /* 36bbeaf6c0SSean Eric Fagan * The main module for truss. Suprisingly simple, but, then, the other 37bbeaf6c0SSean Eric Fagan * files handle the bulk of the work. And, of course, the kernel has to 38bbeaf6c0SSean Eric Fagan * do a lot of the work :). 39bbeaf6c0SSean Eric Fagan */ 40bbeaf6c0SSean Eric Fagan 41580e0a2bSDag-Erling Smørgrav #include <sys/param.h> 42580e0a2bSDag-Erling Smørgrav #include <sys/ioctl.h> 43580e0a2bSDag-Erling Smørgrav #include <sys/pioctl.h> 445cdf6a13SMartin Cracauer #include <sys/types.h> 451d631f7eSMike Barcroft #include <sys/time.h> 465cdf6a13SMartin Cracauer #include <sys/resource.h> 47580e0a2bSDag-Erling Smørgrav 48d75300bfSAlfred Perlstein #include <ctype.h> 493cf51049SPhilippe Charnier #include <err.h> 503cf51049SPhilippe Charnier #include <errno.h> 513cf51049SPhilippe Charnier #include <fcntl.h> 523cf51049SPhilippe Charnier #include <signal.h> 53bbeaf6c0SSean Eric Fagan #include <stdio.h> 54bbeaf6c0SSean Eric Fagan #include <stdlib.h> 55bbeaf6c0SSean Eric Fagan #include <string.h> 5637169f94SMatthew N. Dodd #include <time.h> 5795c4ef65SPeter Wemm #include <unistd.h> 58bbeaf6c0SSean Eric Fagan 59ec0bed25SMatthew N. Dodd #include "truss.h" 601be5d704SMark Murray #include "extern.h" 61bbeaf6c0SSean Eric Fagan 62bbeaf6c0SSean Eric Fagan /* 63ec0bed25SMatthew N. Dodd * It's difficult to parameterize this because it must be 64ec0bed25SMatthew N. Dodd * accessible in a signal handler. 65bbeaf6c0SSean Eric Fagan */ 66bbeaf6c0SSean Eric Fagan 67bbeaf6c0SSean Eric Fagan int Procfd; 68bbeaf6c0SSean Eric Fagan 695321ae86SAlfred Perlstein static void 703cf51049SPhilippe Charnier usage(void) 713cf51049SPhilippe Charnier { 723cf51049SPhilippe Charnier fprintf(stderr, "%s\n%s\n", 730cf21b4fSBrian Somers "usage: truss [-faedDS] [-o file] [-s strsize] -p pid", 740cf21b4fSBrian Somers " truss [-faedDS] [-o file] [-s strsize] command [args]"); 75bbeaf6c0SSean Eric Fagan exit(1); 76bbeaf6c0SSean Eric Fagan } 77bbeaf6c0SSean Eric Fagan 783625b514SSean Eric Fagan /* 793625b514SSean Eric Fagan * WARNING! "FreeBSD a.out" must be first, or set_etype will not 803625b514SSean Eric Fagan * work correctly. 813625b514SSean Eric Fagan */ 82bbeaf6c0SSean Eric Fagan struct ex_types { 831be5d704SMark Murray const char *type; 84ec0bed25SMatthew N. Dodd void (*enter_syscall)(struct trussinfo *, int); 851bcb5f5aSMarcel Moolenaar long (*exit_syscall)(struct trussinfo *, int); 86bbeaf6c0SSean Eric Fagan } ex_types[] = { 8750cc4492SSean Eric Fagan #ifdef __alpha__ 8850cc4492SSean Eric Fagan { "FreeBSD ELF", alpha_syscall_entry, alpha_syscall_exit }, 8950cc4492SSean Eric Fagan #endif 90a5d31d16SDavid Malone #ifdef __amd64__ 91a5d31d16SDavid Malone { "FreeBSD ELF64", amd64_syscall_entry, amd64_syscall_exit }, 92a5d31d16SDavid Malone #endif 9350cc4492SSean Eric Fagan #ifdef __i386__ 94bbeaf6c0SSean Eric Fagan { "FreeBSD a.out", i386_syscall_entry, i386_syscall_exit }, 9587893934SPeter Wemm { "FreeBSD ELF", i386_syscall_entry, i386_syscall_exit }, 960629483cSMatthew N. Dodd { "FreeBSD ELF32", i386_syscall_entry, i386_syscall_exit }, 97bbeaf6c0SSean Eric Fagan { "Linux ELF", i386_linux_syscall_entry, i386_linux_syscall_exit }, 9850cc4492SSean Eric Fagan #endif 99a3e32192SMarcel Moolenaar #ifdef __ia64__ 100a3e32192SMarcel Moolenaar { "FreeBSD ELF64", ia64_syscall_entry, ia64_syscall_exit }, 101a3e32192SMarcel Moolenaar #endif 102f84c971aSJake Burkholder #ifdef __sparc64__ 103f84c971aSJake Burkholder { "FreeBSD ELF64", sparc64_syscall_entry, sparc64_syscall_exit }, 104f84c971aSJake Burkholder #endif 105bbeaf6c0SSean Eric Fagan { 0, 0, 0 }, 106bbeaf6c0SSean Eric Fagan }; 107bbeaf6c0SSean Eric Fagan 108bbeaf6c0SSean Eric Fagan /* 109bbeaf6c0SSean Eric Fagan * Set the execution type. This is called after every exec, and when 110bbeaf6c0SSean Eric Fagan * a process is first monitored. The procfs pseudo-file "etype" has 111bbeaf6c0SSean Eric Fagan * the execution module type -- see /proc/curproc/etype for an example. 112bbeaf6c0SSean Eric Fagan */ 113bbeaf6c0SSean Eric Fagan 114bbeaf6c0SSean Eric Fagan static struct ex_types * 1155321ae86SAlfred Perlstein set_etype(struct trussinfo *trussinfo) 1165321ae86SAlfred Perlstein { 117bbeaf6c0SSean Eric Fagan struct ex_types *funcs; 118bbeaf6c0SSean Eric Fagan char etype[24]; 1191be5d704SMark Murray char progt[32]; 120bbeaf6c0SSean Eric Fagan int fd; 121bbeaf6c0SSean Eric Fagan 122ec0bed25SMatthew N. Dodd sprintf(etype, "/proc/%d/etype", trussinfo->pid); 123bbeaf6c0SSean Eric Fagan if ((fd = open(etype, O_RDONLY)) == -1) { 1241be5d704SMark Murray strcpy(progt, "FreeBSD a.out"); 125bbeaf6c0SSean Eric Fagan } else { 1261be5d704SMark Murray int len = read(fd, progt, sizeof(progt)); 1271be5d704SMark Murray progt[len-1] = '\0'; 12887893934SPeter Wemm close(fd); 129bbeaf6c0SSean Eric Fagan } 130bbeaf6c0SSean Eric Fagan 131bbeaf6c0SSean Eric Fagan for (funcs = ex_types; funcs->type; funcs++) 1321be5d704SMark Murray if (!strcmp(funcs->type, progt)) 133bbeaf6c0SSean Eric Fagan break; 134bbeaf6c0SSean Eric Fagan 1354525f3a8SDag-Erling Smørgrav if (funcs->type == NULL) { 1363625b514SSean Eric Fagan funcs = &ex_types[0]; 137b956c13cSPhilippe Charnier warn("execution type %s is not supported -- using %s", 1384525f3a8SDag-Erling Smørgrav progt, funcs->type); 1393625b514SSean Eric Fagan } 1405321ae86SAlfred Perlstein return (funcs); 141bbeaf6c0SSean Eric Fagan } 142bbeaf6c0SSean Eric Fagan 143d75300bfSAlfred Perlstein char * 144d75300bfSAlfred Perlstein strsig(int sig) 145d75300bfSAlfred Perlstein { 146d75300bfSAlfred Perlstein char *ret; 147d75300bfSAlfred Perlstein 148d75300bfSAlfred Perlstein ret = NULL; 149d75300bfSAlfred Perlstein if (sig > 0 && sig < NSIG) { 150d75300bfSAlfred Perlstein int i; 151d75300bfSAlfred Perlstein asprintf(&ret, "sig%s", sys_signame[sig]); 152d75300bfSAlfred Perlstein if (ret == NULL) 153d75300bfSAlfred Perlstein return (NULL); 154d75300bfSAlfred Perlstein for (i = 0; ret[i] != '\0'; ++i) 155d75300bfSAlfred Perlstein ret[i] = toupper(ret[i]); 156d75300bfSAlfred Perlstein } 157d75300bfSAlfred Perlstein return (ret); 158d75300bfSAlfred Perlstein } 159d75300bfSAlfred Perlstein 1603cf51049SPhilippe Charnier int 1615321ae86SAlfred Perlstein main(int ac, char **av) 1625321ae86SAlfred Perlstein { 163bbeaf6c0SSean Eric Fagan int c; 164bbeaf6c0SSean Eric Fagan int i; 165bbeaf6c0SSean Eric Fagan char **command; 166bbeaf6c0SSean Eric Fagan struct procfs_status pfs; 167bbeaf6c0SSean Eric Fagan struct ex_types *funcs; 16872aa911aSAlfred Perlstein int in_exec, sigexit, initial_open; 16972aa911aSAlfred Perlstein char *fname; 170ec0bed25SMatthew N. Dodd struct trussinfo *trussinfo; 171d75300bfSAlfred Perlstein char *signame; 172bbeaf6c0SSean Eric Fagan 17372aa911aSAlfred Perlstein in_exec = 0; 17472aa911aSAlfred Perlstein sigexit = 0; 17572aa911aSAlfred Perlstein fname = NULL; 17672aa911aSAlfred Perlstein initial_open = 1; 17772aa911aSAlfred Perlstein 178ec0bed25SMatthew N. Dodd /* Initialize the trussinfo struct */ 179ec0bed25SMatthew N. Dodd trussinfo = (struct trussinfo *)malloc(sizeof(struct trussinfo)); 180ec0bed25SMatthew N. Dodd if (trussinfo == NULL) 181ec0bed25SMatthew N. Dodd errx(1, "malloc() failed"); 182ec0bed25SMatthew N. Dodd bzero(trussinfo, sizeof(struct trussinfo)); 183ec0bed25SMatthew N. Dodd trussinfo->outfile = stderr; 1840cf21b4fSBrian Somers trussinfo->strsize = 32; 185ec0bed25SMatthew N. Dodd 1860cf21b4fSBrian Somers while ((c = getopt(ac, av, "p:o:faedDs:S")) != -1) { 187bbeaf6c0SSean Eric Fagan switch (c) { 188bbeaf6c0SSean Eric Fagan case 'p': /* specified pid */ 189ec0bed25SMatthew N. Dodd trussinfo->pid = atoi(optarg); 190bbeaf6c0SSean Eric Fagan break; 191c03bfcc8SMatthew N. Dodd case 'f': /* Follow fork()'s */ 192c03bfcc8SMatthew N. Dodd trussinfo->flags |= FOLLOWFORKS; 193c03bfcc8SMatthew N. Dodd break; 1949897b203SMatthew N. Dodd case 'a': /* Print execve() argument strings. */ 1959897b203SMatthew N. Dodd trussinfo->flags |= EXECVEARGS; 1969897b203SMatthew N. Dodd break; 1979897b203SMatthew N. Dodd case 'e': /* Print execve() environment strings. */ 1989897b203SMatthew N. Dodd trussinfo->flags |= EXECVEENVS; 1999897b203SMatthew N. Dodd break; 2000d0bd00eSMatthew N. Dodd case 'd': /* Absolute timestamps */ 2010d0bd00eSMatthew N. Dodd trussinfo->flags |= ABSOLUTETIMESTAMPS; 2020d0bd00eSMatthew N. Dodd break; 2030d0bd00eSMatthew N. Dodd case 'D': /* Relative timestamps */ 2040d0bd00eSMatthew N. Dodd trussinfo->flags |= RELATIVETIMESTAMPS; 2050d0bd00eSMatthew N. Dodd break; 206bbeaf6c0SSean Eric Fagan case 'o': /* Specified output file */ 2073cf51049SPhilippe Charnier fname = optarg; 208bbeaf6c0SSean Eric Fagan break; 2090cf21b4fSBrian Somers case 's': /* Specified string size */ 2100cf21b4fSBrian Somers trussinfo->strsize = atoi(optarg); 2110cf21b4fSBrian Somers break; 212bbeaf6c0SSean Eric Fagan case 'S': /* Don't trace signals */ 213ec0bed25SMatthew N. Dodd trussinfo->flags |= NOSIGS; 214bbeaf6c0SSean Eric Fagan break; 215bbeaf6c0SSean Eric Fagan default: 216bbeaf6c0SSean Eric Fagan usage(); 217bbeaf6c0SSean Eric Fagan } 218bbeaf6c0SSean Eric Fagan } 219bbeaf6c0SSean Eric Fagan 220bbeaf6c0SSean Eric Fagan ac -= optind; av += optind; 2215321ae86SAlfred Perlstein if ((trussinfo->pid == 0 && ac == 0) || 2225321ae86SAlfred Perlstein (trussinfo->pid != 0 && ac != 0)) 223bbeaf6c0SSean Eric Fagan usage(); 224bbeaf6c0SSean Eric Fagan 2253cf51049SPhilippe Charnier if (fname != NULL) { /* Use output file */ 226ec0bed25SMatthew N. Dodd if ((trussinfo->outfile = fopen(fname, "w")) == NULL) 2273cf51049SPhilippe Charnier errx(1, "cannot open %s", fname); 2283cf51049SPhilippe Charnier } 2293cf51049SPhilippe Charnier 230bbeaf6c0SSean Eric Fagan /* 231bbeaf6c0SSean Eric Fagan * If truss starts the process itself, it will ignore some signals -- 232bbeaf6c0SSean Eric Fagan * they should be passed off to the process, which may or may not 233bbeaf6c0SSean Eric Fagan * exit. If, however, we are examining an already-running process, 234bbeaf6c0SSean Eric Fagan * then we restore the event mask on these same signals. 235bbeaf6c0SSean Eric Fagan */ 236bbeaf6c0SSean Eric Fagan 237ec0bed25SMatthew N. Dodd if (trussinfo->pid == 0) { /* Start a command ourselves */ 238bbeaf6c0SSean Eric Fagan command = av; 239ec0bed25SMatthew N. Dodd trussinfo->pid = setup_and_wait(command); 240bbeaf6c0SSean Eric Fagan signal(SIGINT, SIG_IGN); 241bbeaf6c0SSean Eric Fagan signal(SIGTERM, SIG_IGN); 242bbeaf6c0SSean Eric Fagan signal(SIGQUIT, SIG_IGN); 243bbeaf6c0SSean Eric Fagan } else { 244bbeaf6c0SSean Eric Fagan signal(SIGINT, restore_proc); 245bbeaf6c0SSean Eric Fagan signal(SIGTERM, restore_proc); 246bbeaf6c0SSean Eric Fagan signal(SIGQUIT, restore_proc); 247bbeaf6c0SSean Eric Fagan } 248bbeaf6c0SSean Eric Fagan 249bbeaf6c0SSean Eric Fagan 250bbeaf6c0SSean Eric Fagan /* 251bbeaf6c0SSean Eric Fagan * At this point, if we started the process, it is stopped waiting to 252bbeaf6c0SSean Eric Fagan * be woken up, either in exit() or in execve(). 253bbeaf6c0SSean Eric Fagan */ 254bbeaf6c0SSean Eric Fagan 255c03bfcc8SMatthew N. Dodd START_TRACE: 256ec0bed25SMatthew N. Dodd Procfd = start_tracing( 25772aa911aSAlfred Perlstein trussinfo->pid, initial_open, 25872aa911aSAlfred Perlstein S_EXEC | S_SCE | S_SCX | S_CORE | S_EXIT | 259c03bfcc8SMatthew N. Dodd ((trussinfo->flags & NOSIGS) ? 0 : S_SIG), 260c03bfcc8SMatthew N. Dodd ((trussinfo->flags & FOLLOWFORKS) ? PF_FORK : 0)); 26172aa911aSAlfred Perlstein initial_open = 0; 26289361835SSean Eric Fagan if (Procfd == -1) 2635321ae86SAlfred Perlstein return (0); 26489361835SSean Eric Fagan 265bbeaf6c0SSean Eric Fagan pfs.why = 0; 266bbeaf6c0SSean Eric Fagan 267ec0bed25SMatthew N. Dodd funcs = set_etype(trussinfo); 268bbeaf6c0SSean Eric Fagan /* 269bbeaf6c0SSean Eric Fagan * At this point, it's a simple loop, waiting for the process to 270bbeaf6c0SSean Eric Fagan * stop, finding out why, printing out why, and then continuing it. 271bbeaf6c0SSean Eric Fagan * All of the grunt work is done in the support routines. 272bbeaf6c0SSean Eric Fagan */ 273bbeaf6c0SSean Eric Fagan 274203098d8SMatthew N. Dodd clock_gettime(CLOCK_REALTIME, &trussinfo->start_time); 2750d0bd00eSMatthew N. Dodd 276bbeaf6c0SSean Eric Fagan do { 277bbeaf6c0SSean Eric Fagan int val = 0; 278bbeaf6c0SSean Eric Fagan 279bbeaf6c0SSean Eric Fagan if (ioctl(Procfd, PIOCWAIT, &pfs) == -1) 2803cf51049SPhilippe Charnier warn("PIOCWAIT top of loop"); 281bbeaf6c0SSean Eric Fagan else { 282bbeaf6c0SSean Eric Fagan switch(i = pfs.why) { 283bbeaf6c0SSean Eric Fagan case S_SCE: 284ec0bed25SMatthew N. Dodd funcs->enter_syscall(trussinfo, pfs.val); 2855321ae86SAlfred Perlstein clock_gettime(CLOCK_REALTIME, 2865321ae86SAlfred Perlstein &trussinfo->before); 287bbeaf6c0SSean Eric Fagan break; 288bbeaf6c0SSean Eric Fagan case S_SCX: 2895321ae86SAlfred Perlstein clock_gettime(CLOCK_REALTIME, 2905321ae86SAlfred Perlstein &trussinfo->after); 291bbeaf6c0SSean Eric Fagan /* 2925321ae86SAlfred Perlstein * This is so we don't get two messages for 2935321ae86SAlfred Perlstein * an exec -- one for the S_EXEC, and one for 2945321ae86SAlfred Perlstein * the syscall exit. It also, conveniently, 2955321ae86SAlfred Perlstein * ensures that the first message printed out 2965321ae86SAlfred Perlstein * isn't the return-from-syscall used to 2975321ae86SAlfred Perlstein * create the process. 298bbeaf6c0SSean Eric Fagan */ 299bbeaf6c0SSean Eric Fagan if (in_exec) { 300bbeaf6c0SSean Eric Fagan in_exec = 0; 301bbeaf6c0SSean Eric Fagan break; 302bbeaf6c0SSean Eric Fagan } 303c03bfcc8SMatthew N. Dodd 3045321ae86SAlfred Perlstein if (trussinfo->in_fork && 3055321ae86SAlfred Perlstein (trussinfo->flags & FOLLOWFORKS)) { 306c03bfcc8SMatthew N. Dodd int childpid; 307c03bfcc8SMatthew N. Dodd 308c03bfcc8SMatthew N. Dodd trussinfo->in_fork = 0; 3095321ae86SAlfred Perlstein childpid = 3105321ae86SAlfred Perlstein funcs->exit_syscall(trussinfo, 3115321ae86SAlfred Perlstein pfs.val); 312c03bfcc8SMatthew N. Dodd 313c03bfcc8SMatthew N. Dodd /* 3145321ae86SAlfred Perlstein * Fork a new copy of ourself to trace 3155321ae86SAlfred Perlstein * the child of the original traced 3165321ae86SAlfred Perlstein * process. 317c03bfcc8SMatthew N. Dodd */ 318c03bfcc8SMatthew N. Dodd if (fork() == 0) { 319c03bfcc8SMatthew N. Dodd trussinfo->pid = childpid; 320c03bfcc8SMatthew N. Dodd goto START_TRACE; 321c03bfcc8SMatthew N. Dodd } 322c03bfcc8SMatthew N. Dodd break; 323c03bfcc8SMatthew N. Dodd } 324ec0bed25SMatthew N. Dodd funcs->exit_syscall(trussinfo, pfs.val); 325bbeaf6c0SSean Eric Fagan break; 326bbeaf6c0SSean Eric Fagan case S_SIG: 327d75300bfSAlfred Perlstein signame = strsig(pfs.val); 3285321ae86SAlfred Perlstein fprintf(trussinfo->outfile, 3295321ae86SAlfred Perlstein "SIGNAL %lu (%s)\n", pfs.val, 330d75300bfSAlfred Perlstein signame == NULL ? "?" : signame); 331d75300bfSAlfred Perlstein free(signame); 3329a4902a9SMartin Cracauer sigexit = pfs.val; 333bbeaf6c0SSean Eric Fagan break; 334bbeaf6c0SSean Eric Fagan case S_EXIT: 3355321ae86SAlfred Perlstein fprintf(trussinfo->outfile, 3365321ae86SAlfred Perlstein "process exit, rval = %lu\n", pfs.val); 337bbeaf6c0SSean Eric Fagan break; 338bbeaf6c0SSean Eric Fagan case S_EXEC: 339ec0bed25SMatthew N. Dodd funcs = set_etype(trussinfo); 340bbeaf6c0SSean Eric Fagan in_exec = 1; 341bbeaf6c0SSean Eric Fagan break; 342bbeaf6c0SSean Eric Fagan default: 3435321ae86SAlfred Perlstein fprintf(trussinfo->outfile, 3445321ae86SAlfred Perlstein "Process stopped because of: %d\n", i); 345bbeaf6c0SSean Eric Fagan break; 346bbeaf6c0SSean Eric Fagan } 347bbeaf6c0SSean Eric Fagan } 34889361835SSean Eric Fagan if (ioctl(Procfd, PIOCCONT, val) == -1) { 349ec0bed25SMatthew N. Dodd if (kill(trussinfo->pid, 0) == -1 && errno == ESRCH) 35089361835SSean Eric Fagan break; 35189361835SSean Eric Fagan else 3523cf51049SPhilippe Charnier warn("PIOCCONT"); 35389361835SSean Eric Fagan } 354bbeaf6c0SSean Eric Fagan } while (pfs.why != S_EXIT); 355ec0bed25SMatthew N. Dodd fflush(trussinfo->outfile); 3569a4902a9SMartin Cracauer if (sigexit) { 3575cdf6a13SMartin Cracauer struct rlimit rlp; 3585cdf6a13SMartin Cracauer 3595cdf6a13SMartin Cracauer rlp.rlim_cur = 0; 3605cdf6a13SMartin Cracauer rlp.rlim_max = 0; 3615cdf6a13SMartin Cracauer setrlimit(RLIMIT_CORE, &rlp); 3629a4902a9SMartin Cracauer (void) signal(sigexit, SIG_DFL); 3639a4902a9SMartin Cracauer (void) kill(getpid(), sigexit); 3649a4902a9SMartin Cracauer } 3655321ae86SAlfred Perlstein return (0); 366bbeaf6c0SSean Eric Fagan } 367