1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 28*0Sstevel@tonic-gate 29*0Sstevel@tonic-gate #include <stdio.h> 30*0Sstevel@tonic-gate #include <stdlib.h> 31*0Sstevel@tonic-gate #include <unistd.h> 32*0Sstevel@tonic-gate #include <ctype.h> 33*0Sstevel@tonic-gate #include <fcntl.h> 34*0Sstevel@tonic-gate #include <string.h> 35*0Sstevel@tonic-gate #include <signal.h> 36*0Sstevel@tonic-gate #include <stddef.h> 37*0Sstevel@tonic-gate #include <sys/types.h> 38*0Sstevel@tonic-gate #include <sys/stat.h> 39*0Sstevel@tonic-gate #include <libproc.h> 40*0Sstevel@tonic-gate 41*0Sstevel@tonic-gate /* evil knowledge of libc internals */ 42*0Sstevel@tonic-gate #include "../../../lib/libc/inc/thr_uberdata.h" 43*0Sstevel@tonic-gate 44*0Sstevel@tonic-gate #define MAX_SYMNAMLEN 1024 /* Recommended max symbol name length */ 45*0Sstevel@tonic-gate 46*0Sstevel@tonic-gate static char *sigflags(int, int); 47*0Sstevel@tonic-gate static int look(char *); 48*0Sstevel@tonic-gate static void perr(char *); 49*0Sstevel@tonic-gate static int usage(void); 50*0Sstevel@tonic-gate static uintptr_t deinterpose(int, void *, psinfo_t *, struct sigaction *); 51*0Sstevel@tonic-gate 52*0Sstevel@tonic-gate static char *command; 53*0Sstevel@tonic-gate static char *procname; 54*0Sstevel@tonic-gate static int all_flag = 0; 55*0Sstevel@tonic-gate static int lookuphandlers_flag = 1; 56*0Sstevel@tonic-gate 57*0Sstevel@tonic-gate int 58*0Sstevel@tonic-gate main(int argc, char **argv) 59*0Sstevel@tonic-gate { 60*0Sstevel@tonic-gate int rc = 0; 61*0Sstevel@tonic-gate int c; 62*0Sstevel@tonic-gate struct rlimit rlim; 63*0Sstevel@tonic-gate 64*0Sstevel@tonic-gate if ((command = strrchr(argv[0], '/')) != NULL) 65*0Sstevel@tonic-gate command++; 66*0Sstevel@tonic-gate else 67*0Sstevel@tonic-gate command = argv[0]; 68*0Sstevel@tonic-gate 69*0Sstevel@tonic-gate while ((c = getopt(argc, argv, "an")) != EOF) { 70*0Sstevel@tonic-gate switch (c) { 71*0Sstevel@tonic-gate case 'a': 72*0Sstevel@tonic-gate all_flag = 1; 73*0Sstevel@tonic-gate break; 74*0Sstevel@tonic-gate case 'n': 75*0Sstevel@tonic-gate lookuphandlers_flag = 0; 76*0Sstevel@tonic-gate break; 77*0Sstevel@tonic-gate default: 78*0Sstevel@tonic-gate return (usage()); 79*0Sstevel@tonic-gate } 80*0Sstevel@tonic-gate } 81*0Sstevel@tonic-gate 82*0Sstevel@tonic-gate if (argc - optind < 1) { 83*0Sstevel@tonic-gate return (usage()); 84*0Sstevel@tonic-gate } 85*0Sstevel@tonic-gate 86*0Sstevel@tonic-gate /* 87*0Sstevel@tonic-gate * Make sure we'll have enough file descriptors to handle a target 88*0Sstevel@tonic-gate * that has many many mappings. 89*0Sstevel@tonic-gate */ 90*0Sstevel@tonic-gate if (getrlimit(RLIMIT_NOFILE, &rlim) == 0) { 91*0Sstevel@tonic-gate rlim.rlim_cur = rlim.rlim_max; 92*0Sstevel@tonic-gate (void) setrlimit(RLIMIT_NOFILE, &rlim); 93*0Sstevel@tonic-gate } 94*0Sstevel@tonic-gate 95*0Sstevel@tonic-gate for (; optind != argc; optind++) { 96*0Sstevel@tonic-gate rc += look(argv[optind]); 97*0Sstevel@tonic-gate } 98*0Sstevel@tonic-gate 99*0Sstevel@tonic-gate return (rc); 100*0Sstevel@tonic-gate } 101*0Sstevel@tonic-gate 102*0Sstevel@tonic-gate static int 103*0Sstevel@tonic-gate usage(void) 104*0Sstevel@tonic-gate { 105*0Sstevel@tonic-gate (void) fprintf(stderr, "usage:\t%s [-n] pid ...\n", command); 106*0Sstevel@tonic-gate (void) fprintf(stderr, " (report process signal actions)\n"); 107*0Sstevel@tonic-gate 108*0Sstevel@tonic-gate return (2); 109*0Sstevel@tonic-gate } 110*0Sstevel@tonic-gate 111*0Sstevel@tonic-gate static uintptr_t 112*0Sstevel@tonic-gate uberdata_addr(struct ps_prochandle *Pr, char dmodel) 113*0Sstevel@tonic-gate { 114*0Sstevel@tonic-gate GElf_Sym sym; 115*0Sstevel@tonic-gate 116*0Sstevel@tonic-gate if (Plookup_by_name(Pr, "libc.so", "_tdb_bootstrap", &sym) < 0) 117*0Sstevel@tonic-gate return (NULL); 118*0Sstevel@tonic-gate #ifdef _LP64 119*0Sstevel@tonic-gate if (dmodel != PR_MODEL_NATIVE) { 120*0Sstevel@tonic-gate caddr32_t uaddr; 121*0Sstevel@tonic-gate caddr32_t addr; 122*0Sstevel@tonic-gate 123*0Sstevel@tonic-gate if (Pread(Pr, &addr, sizeof (addr), sym.st_value) 124*0Sstevel@tonic-gate == sizeof (addr) && 125*0Sstevel@tonic-gate addr != 0 && 126*0Sstevel@tonic-gate Pread(Pr, &uaddr, sizeof (uaddr), (uintptr_t)addr) 127*0Sstevel@tonic-gate == sizeof (uaddr) && 128*0Sstevel@tonic-gate uaddr != 0) 129*0Sstevel@tonic-gate return ((uintptr_t)uaddr); 130*0Sstevel@tonic-gate } 131*0Sstevel@tonic-gate #endif 132*0Sstevel@tonic-gate if (dmodel == PR_MODEL_NATIVE) { 133*0Sstevel@tonic-gate uintptr_t uaddr; 134*0Sstevel@tonic-gate uintptr_t addr; 135*0Sstevel@tonic-gate 136*0Sstevel@tonic-gate if (Pread(Pr, &addr, sizeof (addr), sym.st_value) 137*0Sstevel@tonic-gate == sizeof (addr) && 138*0Sstevel@tonic-gate addr != 0 && 139*0Sstevel@tonic-gate Pread(Pr, &uaddr, sizeof (uaddr), addr) 140*0Sstevel@tonic-gate == sizeof (uaddr) && 141*0Sstevel@tonic-gate uaddr != 0) 142*0Sstevel@tonic-gate return (uaddr); 143*0Sstevel@tonic-gate } 144*0Sstevel@tonic-gate if (Plookup_by_name(Pr, "libc.so", "_uberdata", &sym) < 0) 145*0Sstevel@tonic-gate return (0); 146*0Sstevel@tonic-gate return (sym.st_value); 147*0Sstevel@tonic-gate } 148*0Sstevel@tonic-gate 149*0Sstevel@tonic-gate /* 150*0Sstevel@tonic-gate * Iterator function used to generate the process sigmask 151*0Sstevel@tonic-gate * from the individual lwp sigmasks. 152*0Sstevel@tonic-gate */ 153*0Sstevel@tonic-gate static int 154*0Sstevel@tonic-gate lwp_iter(void *cd, const lwpstatus_t *lwpstatus) 155*0Sstevel@tonic-gate { 156*0Sstevel@tonic-gate sigset_t *ssp = cd; 157*0Sstevel@tonic-gate 158*0Sstevel@tonic-gate ssp->__sigbits[0] &= lwpstatus->pr_lwphold.__sigbits[0]; 159*0Sstevel@tonic-gate ssp->__sigbits[1] &= lwpstatus->pr_lwphold.__sigbits[1]; 160*0Sstevel@tonic-gate ssp->__sigbits[2] &= lwpstatus->pr_lwphold.__sigbits[2]; 161*0Sstevel@tonic-gate ssp->__sigbits[3] &= lwpstatus->pr_lwphold.__sigbits[3]; 162*0Sstevel@tonic-gate 163*0Sstevel@tonic-gate /* 164*0Sstevel@tonic-gate * Return non-zero to terminate the iteration 165*0Sstevel@tonic-gate * if the sigmask has become all zeros. 166*0Sstevel@tonic-gate */ 167*0Sstevel@tonic-gate return ((ssp->__sigbits[0] | ssp->__sigbits[1] | 168*0Sstevel@tonic-gate ssp->__sigbits[2] | ssp->__sigbits[3]) == 0); 169*0Sstevel@tonic-gate } 170*0Sstevel@tonic-gate 171*0Sstevel@tonic-gate static int 172*0Sstevel@tonic-gate look(char *arg) 173*0Sstevel@tonic-gate { 174*0Sstevel@tonic-gate char pathname[100]; 175*0Sstevel@tonic-gate struct stat statb; 176*0Sstevel@tonic-gate int fd = -1; 177*0Sstevel@tonic-gate int sig, gcode; 178*0Sstevel@tonic-gate sigset_t holdmask; 179*0Sstevel@tonic-gate int maxsig; 180*0Sstevel@tonic-gate struct sigaction *action = NULL; 181*0Sstevel@tonic-gate psinfo_t psinfo; 182*0Sstevel@tonic-gate const psinfo_t *psinfop; 183*0Sstevel@tonic-gate struct ps_prochandle *Pr = NULL; 184*0Sstevel@tonic-gate uintptr_t uberaddr; 185*0Sstevel@tonic-gate uintptr_t aharraddr; 186*0Sstevel@tonic-gate uintptr_t intfnaddr; 187*0Sstevel@tonic-gate size_t aharrlen; 188*0Sstevel@tonic-gate void *aharr = NULL; 189*0Sstevel@tonic-gate int error = 1; 190*0Sstevel@tonic-gate 191*0Sstevel@tonic-gate procname = arg; /* for perr() */ 192*0Sstevel@tonic-gate if ((Pr = proc_arg_grab(arg, PR_ARG_PIDS, PGRAB_RDONLY|PGRAB_FORCE, 193*0Sstevel@tonic-gate &gcode)) == NULL || (psinfop = Ppsinfo(Pr)) == NULL) { 194*0Sstevel@tonic-gate (void) fprintf(stderr, "%s: cannot examine %s: %s\n", 195*0Sstevel@tonic-gate command, arg, Pgrab_error(gcode)); 196*0Sstevel@tonic-gate goto look_error; 197*0Sstevel@tonic-gate } 198*0Sstevel@tonic-gate (void) memcpy(&psinfo, psinfop, sizeof (psinfo_t)); 199*0Sstevel@tonic-gate proc_unctrl_psinfo(&psinfo); 200*0Sstevel@tonic-gate 201*0Sstevel@tonic-gate (void) sprintf(pathname, "/proc/%d/sigact", (int)psinfo.pr_pid); 202*0Sstevel@tonic-gate if ((fd = open(pathname, O_RDONLY)) < 0) { 203*0Sstevel@tonic-gate perr("open sigact"); 204*0Sstevel@tonic-gate goto look_error; 205*0Sstevel@tonic-gate } 206*0Sstevel@tonic-gate 207*0Sstevel@tonic-gate if (fstat(fd, &statb) != 0) { 208*0Sstevel@tonic-gate perr("fstat sigact"); 209*0Sstevel@tonic-gate goto look_error; 210*0Sstevel@tonic-gate } 211*0Sstevel@tonic-gate maxsig = statb.st_size / sizeof (struct sigaction); 212*0Sstevel@tonic-gate action = malloc(maxsig * sizeof (struct sigaction)); 213*0Sstevel@tonic-gate if (action == NULL) { 214*0Sstevel@tonic-gate (void) fprintf(stderr, 215*0Sstevel@tonic-gate "%s: cannot malloc() space for %d sigaction structures\n", 216*0Sstevel@tonic-gate command, maxsig); 217*0Sstevel@tonic-gate goto look_error; 218*0Sstevel@tonic-gate } 219*0Sstevel@tonic-gate if (read(fd, (char *)action, maxsig * sizeof (struct sigaction)) != 220*0Sstevel@tonic-gate maxsig * sizeof (struct sigaction)) { 221*0Sstevel@tonic-gate perr("read sigact"); 222*0Sstevel@tonic-gate goto look_error; 223*0Sstevel@tonic-gate } 224*0Sstevel@tonic-gate (void) close(fd); 225*0Sstevel@tonic-gate fd = -1; 226*0Sstevel@tonic-gate 227*0Sstevel@tonic-gate (void) printf("%d:\t%.70s\n", (int)psinfo.pr_pid, psinfo.pr_psargs); 228*0Sstevel@tonic-gate 229*0Sstevel@tonic-gate (void) sigfillset(&holdmask); 230*0Sstevel@tonic-gate (void) Plwp_iter(Pr, lwp_iter, &holdmask); 231*0Sstevel@tonic-gate 232*0Sstevel@tonic-gate if ((uberaddr = uberdata_addr(Pr, psinfo.pr_dmodel)) == 0) { 233*0Sstevel@tonic-gate aharraddr = 0; 234*0Sstevel@tonic-gate aharrlen = 0; 235*0Sstevel@tonic-gate intfnaddr = 0; 236*0Sstevel@tonic-gate } else { 237*0Sstevel@tonic-gate #ifdef _LP64 238*0Sstevel@tonic-gate if (psinfo.pr_dmodel != PR_MODEL_NATIVE) { 239*0Sstevel@tonic-gate caddr32_t addr; 240*0Sstevel@tonic-gate aharraddr = uberaddr + 241*0Sstevel@tonic-gate offsetof(uberdata32_t, siguaction); 242*0Sstevel@tonic-gate aharrlen = sizeof (siguaction32_t) * NSIG; 243*0Sstevel@tonic-gate (void) Pread(Pr, &addr, sizeof (addr), 244*0Sstevel@tonic-gate uberaddr + offsetof(uberdata32_t, sigacthandler)); 245*0Sstevel@tonic-gate intfnaddr = (uintptr_t)addr; 246*0Sstevel@tonic-gate } else 247*0Sstevel@tonic-gate #endif 248*0Sstevel@tonic-gate { 249*0Sstevel@tonic-gate aharraddr = uberaddr + 250*0Sstevel@tonic-gate offsetof(uberdata_t, siguaction); 251*0Sstevel@tonic-gate aharrlen = sizeof (siguaction_t) * NSIG; 252*0Sstevel@tonic-gate (void) Pread(Pr, &intfnaddr, sizeof (intfnaddr), 253*0Sstevel@tonic-gate uberaddr + offsetof(uberdata_t, sigacthandler)); 254*0Sstevel@tonic-gate } 255*0Sstevel@tonic-gate } 256*0Sstevel@tonic-gate 257*0Sstevel@tonic-gate if (aharraddr) { 258*0Sstevel@tonic-gate aharr = malloc(aharrlen); 259*0Sstevel@tonic-gate if (aharr == NULL) { 260*0Sstevel@tonic-gate (void) fprintf(stderr, 261*0Sstevel@tonic-gate "%s: cannot malloc() space for actual handler array\n", 262*0Sstevel@tonic-gate command); 263*0Sstevel@tonic-gate goto look_error; 264*0Sstevel@tonic-gate } 265*0Sstevel@tonic-gate 266*0Sstevel@tonic-gate if (Pread(Pr, aharr, aharrlen, aharraddr) != aharrlen) { 267*0Sstevel@tonic-gate (void) fprintf(stderr, 268*0Sstevel@tonic-gate "%s: signal handler data at %p cannot be read.\n", 269*0Sstevel@tonic-gate command, (void *)aharraddr); 270*0Sstevel@tonic-gate free(aharr); 271*0Sstevel@tonic-gate aharr = NULL; 272*0Sstevel@tonic-gate } 273*0Sstevel@tonic-gate } 274*0Sstevel@tonic-gate 275*0Sstevel@tonic-gate for (sig = 1; sig <= maxsig; sig++) { 276*0Sstevel@tonic-gate struct sigaction *sp = &action[sig - 1]; 277*0Sstevel@tonic-gate int caught = 0; 278*0Sstevel@tonic-gate char buf[SIG2STR_MAX]; 279*0Sstevel@tonic-gate char *s; 280*0Sstevel@tonic-gate 281*0Sstevel@tonic-gate /* proc_signame() returns "SIG..."; skip the "SIG" part */ 282*0Sstevel@tonic-gate (void) printf("%s\t", proc_signame(sig, buf, sizeof (buf)) + 3); 283*0Sstevel@tonic-gate 284*0Sstevel@tonic-gate if (prismember(&holdmask, sig)) 285*0Sstevel@tonic-gate (void) printf("blocked,"); 286*0Sstevel@tonic-gate 287*0Sstevel@tonic-gate if (sp->sa_handler == SIG_DFL) 288*0Sstevel@tonic-gate (void) printf("default"); 289*0Sstevel@tonic-gate else if (sp->sa_handler == SIG_IGN) 290*0Sstevel@tonic-gate (void) printf("ignored"); 291*0Sstevel@tonic-gate else 292*0Sstevel@tonic-gate caught = 1; 293*0Sstevel@tonic-gate 294*0Sstevel@tonic-gate if (caught || all_flag) { 295*0Sstevel@tonic-gate uintptr_t haddr; 296*0Sstevel@tonic-gate GElf_Sym hsym; 297*0Sstevel@tonic-gate char hname[MAX_SYMNAMLEN]; 298*0Sstevel@tonic-gate char buf[PRSIGBUFSZ]; 299*0Sstevel@tonic-gate 300*0Sstevel@tonic-gate haddr = (uintptr_t)sp->sa_handler; 301*0Sstevel@tonic-gate 302*0Sstevel@tonic-gate if (aharr && intfnaddr && haddr == intfnaddr) 303*0Sstevel@tonic-gate haddr = deinterpose(sig, aharr, &psinfo, sp); 304*0Sstevel@tonic-gate 305*0Sstevel@tonic-gate if (haddr == (uintptr_t)SIG_DFL) { 306*0Sstevel@tonic-gate if (caught) 307*0Sstevel@tonic-gate (void) printf("default"); 308*0Sstevel@tonic-gate caught = 0; 309*0Sstevel@tonic-gate } else if (haddr == (uintptr_t)SIG_IGN) { 310*0Sstevel@tonic-gate if (caught) 311*0Sstevel@tonic-gate (void) printf("ignored"); 312*0Sstevel@tonic-gate caught = 0; 313*0Sstevel@tonic-gate } else { 314*0Sstevel@tonic-gate if (caught) 315*0Sstevel@tonic-gate (void) printf("caught"); 316*0Sstevel@tonic-gate } 317*0Sstevel@tonic-gate 318*0Sstevel@tonic-gate if (caught || all_flag) { 319*0Sstevel@tonic-gate if (lookuphandlers_flag && haddr > 1 && 320*0Sstevel@tonic-gate Plookup_by_addr(Pr, haddr, hname, 321*0Sstevel@tonic-gate sizeof (hname), &hsym) == 0) 322*0Sstevel@tonic-gate (void) printf("\t%-8s", hname); 323*0Sstevel@tonic-gate else 324*0Sstevel@tonic-gate (void) printf("\t0x%-8lx", 325*0Sstevel@tonic-gate (ulong_t)haddr); 326*0Sstevel@tonic-gate 327*0Sstevel@tonic-gate s = sigflags(sig, sp->sa_flags); 328*0Sstevel@tonic-gate (void) printf("%s", (*s != '\0')? s : "\t0"); 329*0Sstevel@tonic-gate (void) proc_sigset2str(&sp->sa_mask, ",", 1, 330*0Sstevel@tonic-gate buf, sizeof (buf)); 331*0Sstevel@tonic-gate if (buf[0] != '\0') 332*0Sstevel@tonic-gate (void) printf("\t%s", buf); 333*0Sstevel@tonic-gate } 334*0Sstevel@tonic-gate } else if (sig == SIGCLD) { 335*0Sstevel@tonic-gate s = sigflags(sig, 336*0Sstevel@tonic-gate sp->sa_flags & (SA_NOCLDWAIT|SA_NOCLDSTOP)); 337*0Sstevel@tonic-gate if (*s != '\0') 338*0Sstevel@tonic-gate (void) printf("\t\t%s", s); 339*0Sstevel@tonic-gate } 340*0Sstevel@tonic-gate (void) printf("\n"); 341*0Sstevel@tonic-gate } 342*0Sstevel@tonic-gate 343*0Sstevel@tonic-gate error = 0; 344*0Sstevel@tonic-gate 345*0Sstevel@tonic-gate look_error: 346*0Sstevel@tonic-gate if (fd >= 0) 347*0Sstevel@tonic-gate (void) close(fd); 348*0Sstevel@tonic-gate if (aharr) 349*0Sstevel@tonic-gate free(aharr); 350*0Sstevel@tonic-gate if (action) 351*0Sstevel@tonic-gate free(action); 352*0Sstevel@tonic-gate if (Pr) 353*0Sstevel@tonic-gate Prelease(Pr, 0); 354*0Sstevel@tonic-gate return (error); 355*0Sstevel@tonic-gate } 356*0Sstevel@tonic-gate 357*0Sstevel@tonic-gate static void 358*0Sstevel@tonic-gate perr(char *s) 359*0Sstevel@tonic-gate { 360*0Sstevel@tonic-gate if (s) 361*0Sstevel@tonic-gate (void) fprintf(stderr, "%s: ", procname); 362*0Sstevel@tonic-gate else 363*0Sstevel@tonic-gate s = procname; 364*0Sstevel@tonic-gate perror(s); 365*0Sstevel@tonic-gate } 366*0Sstevel@tonic-gate 367*0Sstevel@tonic-gate static char * 368*0Sstevel@tonic-gate sigflags(int sig, int flags) 369*0Sstevel@tonic-gate { 370*0Sstevel@tonic-gate static char code_buf[100]; 371*0Sstevel@tonic-gate char *str = code_buf; 372*0Sstevel@tonic-gate int flagmask = 373*0Sstevel@tonic-gate (SA_ONSTACK|SA_RESETHAND|SA_RESTART|SA_SIGINFO|SA_NODEFER); 374*0Sstevel@tonic-gate 375*0Sstevel@tonic-gate if (sig == SIGCLD) 376*0Sstevel@tonic-gate flagmask |= (SA_NOCLDSTOP|SA_NOCLDWAIT); 377*0Sstevel@tonic-gate 378*0Sstevel@tonic-gate *str = '\0'; 379*0Sstevel@tonic-gate if (flags & ~flagmask) 380*0Sstevel@tonic-gate (void) sprintf(str, ",0x%x,", flags & ~flagmask); 381*0Sstevel@tonic-gate else if (flags == 0) 382*0Sstevel@tonic-gate return (str); 383*0Sstevel@tonic-gate 384*0Sstevel@tonic-gate if (flags & SA_RESTART) 385*0Sstevel@tonic-gate (void) strcat(str, ",RESTART"); 386*0Sstevel@tonic-gate if (flags & SA_RESETHAND) 387*0Sstevel@tonic-gate (void) strcat(str, ",RESETHAND"); 388*0Sstevel@tonic-gate if (flags & SA_ONSTACK) 389*0Sstevel@tonic-gate (void) strcat(str, ",ONSTACK"); 390*0Sstevel@tonic-gate if (flags & SA_SIGINFO) 391*0Sstevel@tonic-gate (void) strcat(str, ",SIGINFO"); 392*0Sstevel@tonic-gate if (flags & SA_NODEFER) 393*0Sstevel@tonic-gate (void) strcat(str, ",NODEFER"); 394*0Sstevel@tonic-gate 395*0Sstevel@tonic-gate if (sig == SIGCLD) { 396*0Sstevel@tonic-gate if (flags & SA_NOCLDWAIT) 397*0Sstevel@tonic-gate (void) strcat(str, ",NOCLDWAIT"); 398*0Sstevel@tonic-gate if (flags & SA_NOCLDSTOP) 399*0Sstevel@tonic-gate (void) strcat(str, ",NOCLDSTOP"); 400*0Sstevel@tonic-gate } 401*0Sstevel@tonic-gate 402*0Sstevel@tonic-gate *str = '\t'; 403*0Sstevel@tonic-gate 404*0Sstevel@tonic-gate return (str); 405*0Sstevel@tonic-gate } 406*0Sstevel@tonic-gate 407*0Sstevel@tonic-gate /*ARGSUSED2*/ 408*0Sstevel@tonic-gate static uintptr_t 409*0Sstevel@tonic-gate deinterpose(int sig, void *aharr, psinfo_t *psinfo, struct sigaction *sp) 410*0Sstevel@tonic-gate { 411*0Sstevel@tonic-gate if (sp->sa_handler == SIG_DFL || sp->sa_handler == SIG_IGN) 412*0Sstevel@tonic-gate return ((uintptr_t)sp->sa_handler); 413*0Sstevel@tonic-gate #ifdef _LP64 414*0Sstevel@tonic-gate if (psinfo->pr_dmodel != PR_MODEL_NATIVE) { 415*0Sstevel@tonic-gate struct sigaction32 *sa32 = (struct sigaction32 *) 416*0Sstevel@tonic-gate ((uintptr_t)aharr + sig * sizeof (siguaction32_t) + 417*0Sstevel@tonic-gate offsetof(siguaction32_t, sig_uaction)); 418*0Sstevel@tonic-gate 419*0Sstevel@tonic-gate sp->sa_flags = sa32->sa_flags; 420*0Sstevel@tonic-gate sp->sa_handler = (void (*)())(uintptr_t)sa32->sa_handler; 421*0Sstevel@tonic-gate (void) memcpy(&sp->sa_mask, &sa32->sa_mask, 422*0Sstevel@tonic-gate sizeof (sp->sa_mask)); 423*0Sstevel@tonic-gate } else 424*0Sstevel@tonic-gate #endif 425*0Sstevel@tonic-gate { 426*0Sstevel@tonic-gate struct sigaction *sa = (struct sigaction *) 427*0Sstevel@tonic-gate ((uintptr_t)aharr + sig * sizeof (siguaction_t) + 428*0Sstevel@tonic-gate offsetof(siguaction_t, sig_uaction)); 429*0Sstevel@tonic-gate 430*0Sstevel@tonic-gate sp->sa_flags = sa->sa_flags; 431*0Sstevel@tonic-gate sp->sa_handler = sa->sa_handler; 432*0Sstevel@tonic-gate sp->sa_mask = sa->sa_mask; 433*0Sstevel@tonic-gate } 434*0Sstevel@tonic-gate return ((uintptr_t)sp->sa_handler); 435*0Sstevel@tonic-gate } 436