psig.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <ctype.h>
#include <fcntl.h>
#include <string.h>
#include <signal.h>
#include <stddef.h>
#include <libproc.h>
/* evil knowledge of libc internals */
#include "../../../lib/libc/inc/thr_uberdata.h"
static char *sigflags(int, int);
static int look(char *);
static void perr(char *);
static int usage(void);
static char *command;
static char *procname;
static int all_flag = 0;
static int lookuphandlers_flag = 1;
int
{
int rc = 0;
int c;
command++;
else
switch (c) {
case 'a':
all_flag = 1;
break;
case 'n':
lookuphandlers_flag = 0;
break;
default:
return (usage());
}
}
return (usage());
}
/*
* Make sure we'll have enough file descriptors to handle a target
* that has many many mappings.
*/
}
}
return (rc);
}
static int
usage(void)
{
return (2);
}
static uintptr_t
{
return (NULL);
#ifdef _LP64
if (dmodel != PR_MODEL_NATIVE) {
== sizeof (addr) &&
addr != 0 &&
== sizeof (uaddr) &&
uaddr != 0)
}
#endif
if (dmodel == PR_MODEL_NATIVE) {
== sizeof (addr) &&
addr != 0 &&
== sizeof (uaddr) &&
uaddr != 0)
return (uaddr);
}
return (0);
}
/*
* Iterator function used to generate the process sigmask
* from the individual lwp sigmasks.
*/
static int
{
/*
* Return non-zero to terminate the iteration
* if the sigmask has become all zeros.
*/
}
static int
{
char pathname[100];
int fd = -1;
int maxsig;
int error = 1;
goto look_error;
}
perr("open sigact");
goto look_error;
}
perr("fstat sigact");
goto look_error;
}
"%s: cannot malloc() space for %d sigaction structures\n",
goto look_error;
}
perr("read sigact");
goto look_error;
}
fd = -1;
(void) sigfillset(&holdmask);
aharraddr = 0;
aharrlen = 0;
intfnaddr = 0;
} else {
#ifdef _LP64
} else
#endif
{
}
}
if (aharraddr) {
"%s: cannot malloc() space for actual handler array\n",
command);
goto look_error;
}
"%s: signal handler data at %p cannot be read.\n",
}
}
int caught = 0;
char buf[SIG2STR_MAX];
char *s;
/* proc_signame() returns "SIG..."; skip the "SIG" part */
(void) printf("blocked,");
(void) printf("default");
(void) printf("ignored");
else
caught = 1;
char hname[MAX_SYMNAMLEN];
char buf[PRSIGBUFSZ];
if (caught)
(void) printf("default");
caught = 0;
if (caught)
(void) printf("ignored");
caught = 0;
} else {
if (caught)
(void) printf("caught");
}
else
(void) printf("\t0x%-8lx",
if (buf[0] != '\0')
}
if (*s != '\0')
(void) printf("\t\t%s", s);
}
(void) printf("\n");
}
error = 0;
if (fd >= 0)
if (aharr)
if (action)
if (Pr)
return (error);
}
static void
perr(char *s)
{
if (s)
else
s = procname;
perror(s);
}
static char *
{
static char code_buf[100];
int flagmask =
*str = '\0';
else if (flags == 0)
return (str);
if (flags & SA_RESTART)
if (flags & SA_RESETHAND)
if (flags & SA_ONSTACK)
if (flags & SA_SIGINFO)
if (flags & SA_NODEFER)
if (flags & SA_NOCLDWAIT)
if (flags & SA_NOCLDSTOP)
}
*str = '\t';
return (str);
}
/*ARGSUSED2*/
static uintptr_t
{
#ifdef _LP64
} else
#endif
{
}
}