2005-02-12 15:53:22 +03:00
|
|
|
/* $NetBSD: ex_shell.c,v 1.13 2005/02/12 12:53:23 aymeric Exp $ */
|
1998-01-09 11:03:16 +03:00
|
|
|
|
1994-01-24 08:52:58 +03:00
|
|
|
/*-
|
1994-03-28 08:28:20 +04:00
|
|
|
* Copyright (c) 1992, 1993, 1994
|
1994-01-24 08:52:58 +03:00
|
|
|
* The Regents of the University of California. All rights reserved.
|
1996-05-20 07:47:00 +04:00
|
|
|
* Copyright (c) 1992, 1993, 1994, 1995, 1996
|
|
|
|
* Keith Bostic. All rights reserved.
|
1994-01-24 08:52:58 +03:00
|
|
|
*
|
1996-05-20 07:47:00 +04:00
|
|
|
* See the LICENSE file for redistribution information.
|
1994-01-24 08:52:58 +03:00
|
|
|
*/
|
|
|
|
|
1996-05-20 07:47:00 +04:00
|
|
|
#include "config.h"
|
|
|
|
|
2002-04-09 05:47:30 +04:00
|
|
|
#include <sys/cdefs.h>
|
1994-01-24 08:52:58 +03:00
|
|
|
#ifndef lint
|
2002-04-09 05:47:30 +04:00
|
|
|
#if 0
|
2001-03-31 15:37:44 +04:00
|
|
|
static const char sccsid[] = "@(#)ex_shell.c 10.38 (Berkeley) 8/19/96";
|
2002-04-09 05:47:30 +04:00
|
|
|
#else
|
2005-02-12 15:53:22 +03:00
|
|
|
__RCSID("$NetBSD: ex_shell.c,v 1.13 2005/02/12 12:53:23 aymeric Exp $");
|
2002-04-09 05:47:30 +04:00
|
|
|
#endif
|
1994-01-24 08:52:58 +03:00
|
|
|
#endif /* not lint */
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
1994-03-28 08:28:20 +04:00
|
|
|
#include <sys/queue.h>
|
1996-05-20 07:47:00 +04:00
|
|
|
#include <sys/wait.h>
|
1994-01-24 08:52:58 +03:00
|
|
|
|
1994-03-28 08:28:20 +04:00
|
|
|
#include <bitstring.h>
|
1994-01-24 08:52:58 +03:00
|
|
|
#include <errno.h>
|
1994-03-28 08:28:20 +04:00
|
|
|
#include <limits.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <stdio.h>
|
1996-05-20 07:47:00 +04:00
|
|
|
#include <stdlib.h>
|
1994-01-24 08:52:58 +03:00
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
1996-05-20 07:47:00 +04:00
|
|
|
#include "../common/common.h"
|
1994-03-28 08:28:20 +04:00
|
|
|
|
1996-05-20 07:47:00 +04:00
|
|
|
static const char *sigmsg __P((int));
|
1994-01-24 08:52:58 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* ex_shell -- :sh[ell]
|
|
|
|
* Invoke the program named in the SHELL environment variable
|
|
|
|
* with the argument -i.
|
1996-05-20 07:47:00 +04:00
|
|
|
*
|
|
|
|
* PUBLIC: int ex_shell __P((SCR *, EXCMD *));
|
1994-01-24 08:52:58 +03:00
|
|
|
*/
|
|
|
|
int
|
1996-05-20 07:47:00 +04:00
|
|
|
ex_shell(sp, cmdp)
|
1994-01-24 08:52:58 +03:00
|
|
|
SCR *sp;
|
1996-05-20 07:47:00 +04:00
|
|
|
EXCMD *cmdp;
|
1994-01-24 08:52:58 +03:00
|
|
|
{
|
1996-05-20 07:47:00 +04:00
|
|
|
int rval;
|
1994-01-24 08:52:58 +03:00
|
|
|
char buf[MAXPATHLEN];
|
|
|
|
|
1996-05-20 07:47:00 +04:00
|
|
|
/* We'll need a shell. */
|
|
|
|
if (opts_empty(sp, O_SHELL, 0))
|
|
|
|
return (1);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX
|
|
|
|
* Assumes all shells use -i.
|
|
|
|
*/
|
1994-01-24 08:52:58 +03:00
|
|
|
(void)snprintf(buf, sizeof(buf), "%s -i", O_STR(sp, O_SHELL));
|
1996-05-20 07:47:00 +04:00
|
|
|
|
2001-03-31 15:37:44 +04:00
|
|
|
/* Restore the window name. */
|
|
|
|
(void)sp->gp->scr_rename(sp, NULL, 0);
|
|
|
|
|
|
|
|
/* If we're still in a vi screen, move out explicitly. */
|
1996-05-20 07:47:00 +04:00
|
|
|
rval = ex_exec_proc(sp, cmdp, buf, NULL, !F_ISSET(sp, SC_SCR_EXWROTE));
|
|
|
|
|
2001-03-31 15:37:44 +04:00
|
|
|
/* Set the window name. */
|
|
|
|
(void)sp->gp->scr_rename(sp, sp->frp->name, 1);
|
|
|
|
|
1996-05-20 07:47:00 +04:00
|
|
|
/*
|
|
|
|
* !!!
|
|
|
|
* Historically, vi didn't require a continue message after the
|
|
|
|
* return of the shell. Match it.
|
|
|
|
*/
|
2001-03-31 15:37:44 +04:00
|
|
|
F_SET(sp, SC_EX_WAIT_NO);
|
1996-05-20 07:47:00 +04:00
|
|
|
|
|
|
|
return (rval);
|
1994-01-24 08:52:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ex_exec_proc --
|
|
|
|
* Run a separate process.
|
1996-05-20 07:47:00 +04:00
|
|
|
*
|
|
|
|
* PUBLIC: int ex_exec_proc __P((SCR *, EXCMD *, char *, const char *, int));
|
1994-01-24 08:52:58 +03:00
|
|
|
*/
|
|
|
|
int
|
1996-05-20 07:47:00 +04:00
|
|
|
ex_exec_proc(sp, cmdp, cmd, msg, need_newline)
|
1994-01-24 08:52:58 +03:00
|
|
|
SCR *sp;
|
1996-05-20 07:47:00 +04:00
|
|
|
EXCMD *cmdp;
|
|
|
|
char *cmd;
|
|
|
|
const char *msg;
|
|
|
|
int need_newline;
|
1994-01-24 08:52:58 +03:00
|
|
|
{
|
2000-05-31 23:49:23 +04:00
|
|
|
GS *gp;
|
1994-01-24 08:52:58 +03:00
|
|
|
const char *name;
|
|
|
|
pid_t pid;
|
|
|
|
|
2000-05-31 23:49:23 +04:00
|
|
|
gp = sp->gp;
|
|
|
|
|
1996-05-20 07:47:00 +04:00
|
|
|
/* We'll need a shell. */
|
|
|
|
if (opts_empty(sp, O_SHELL, 0))
|
1994-01-24 08:52:58 +03:00
|
|
|
return (1);
|
|
|
|
|
1996-05-20 07:47:00 +04:00
|
|
|
/* Enter ex mode. */
|
|
|
|
if (F_ISSET(sp, SC_VI)) {
|
2001-03-31 15:37:44 +04:00
|
|
|
if (gp->scr_screen(sp, SC_EX)) {
|
1996-05-20 07:47:00 +04:00
|
|
|
ex_emsg(sp, cmdp->cmd->name, EXM_NOCANON);
|
|
|
|
return (1);
|
|
|
|
}
|
2000-05-31 23:49:23 +04:00
|
|
|
(void)gp->scr_attr(sp, SA_ALTERNATE, 0);
|
1996-05-20 07:47:00 +04:00
|
|
|
F_SET(sp, SC_SCR_EX | SC_SCR_EXWROTE);
|
|
|
|
}
|
1994-08-17 20:35:35 +04:00
|
|
|
|
1996-05-20 07:47:00 +04:00
|
|
|
/* Put out additional newline, message. */
|
|
|
|
if (need_newline)
|
|
|
|
(void)ex_puts(sp, "\n");
|
|
|
|
if (msg != NULL) {
|
|
|
|
(void)ex_puts(sp, msg);
|
|
|
|
(void)ex_puts(sp, "\n");
|
|
|
|
}
|
|
|
|
(void)ex_fflush(sp);
|
1994-01-24 08:52:58 +03:00
|
|
|
|
|
|
|
switch (pid = vfork()) {
|
|
|
|
case -1: /* Error. */
|
|
|
|
msgq(sp, M_SYSERR, "vfork");
|
1996-05-20 07:47:00 +04:00
|
|
|
return (1);
|
1994-01-24 08:52:58 +03:00
|
|
|
case 0: /* Utility. */
|
|
|
|
if ((name = strrchr(O_STR(sp, O_SHELL), '/')) == NULL)
|
|
|
|
name = O_STR(sp, O_SHELL);
|
|
|
|
else
|
|
|
|
++name;
|
|
|
|
execl(O_STR(sp, O_SHELL), name, "-c", cmd, NULL);
|
1996-05-20 07:47:00 +04:00
|
|
|
msgq_str(sp, M_SYSERR, O_STR(sp, O_SHELL), "execl: %s");
|
1994-01-24 08:52:58 +03:00
|
|
|
_exit(127);
|
|
|
|
/* NOTREACHED */
|
1994-08-17 20:35:35 +04:00
|
|
|
default: /* Parent. */
|
1996-05-20 07:47:00 +04:00
|
|
|
return (proc_wait(sp, (long)pid, cmd, 0, 0));
|
1994-08-17 20:35:35 +04:00
|
|
|
}
|
1996-05-20 07:47:00 +04:00
|
|
|
/* NOTREACHED */
|
|
|
|
}
|
1994-01-24 08:52:58 +03:00
|
|
|
|
1996-05-20 07:47:00 +04:00
|
|
|
/*
|
|
|
|
* proc_wait --
|
|
|
|
* Wait for one of the processes.
|
|
|
|
*
|
|
|
|
* !!!
|
|
|
|
* The pid_t type varies in size from a short to a long depending on the
|
|
|
|
* system. It has to be cast into something or the standard promotion
|
|
|
|
* rules get you. I'm using a long based on the belief that nobody is
|
|
|
|
* going to make it unsigned and it's unlikely to be a quad.
|
|
|
|
*
|
|
|
|
* PUBLIC: int proc_wait __P((SCR *, long, const char *, int, int));
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
proc_wait(sp, pid, cmd, silent, okpipe)
|
|
|
|
SCR *sp;
|
|
|
|
long pid;
|
|
|
|
const char *cmd;
|
|
|
|
int silent, okpipe;
|
|
|
|
{
|
|
|
|
size_t len;
|
|
|
|
int nf, pstat;
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
/* Wait for the utility, ignoring interruptions. */
|
|
|
|
for (;;) {
|
|
|
|
errno = 0;
|
|
|
|
if (waitpid((pid_t)pid, &pstat, 0) != -1)
|
|
|
|
break;
|
|
|
|
if (errno != EINTR) {
|
|
|
|
msgq(sp, M_SYSERR, "waitpid");
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
}
|
1994-01-24 08:52:58 +03:00
|
|
|
|
|
|
|
/*
|
1996-05-20 07:47:00 +04:00
|
|
|
* Display the utility's exit status. Ignore SIGPIPE from the
|
|
|
|
* parent-writer, as that only means that the utility chose to
|
|
|
|
* exit before reading all of its input.
|
1994-01-24 08:52:58 +03:00
|
|
|
*/
|
1996-05-20 07:47:00 +04:00
|
|
|
if (WIFSIGNALED(pstat) && (!okpipe || WTERMSIG(pstat) != SIGPIPE)) {
|
|
|
|
for (; isblank(*cmd); ++cmd);
|
|
|
|
p = msg_print(sp, cmd, &nf);
|
|
|
|
len = strlen(p);
|
|
|
|
msgq(sp, M_ERR, "%.*s%s: received signal: %s%s",
|
2001-05-01 20:46:11 +04:00
|
|
|
(int) MIN(len, 20), p, len > 20 ? " ..." : "",
|
1996-05-20 07:47:00 +04:00
|
|
|
sigmsg(WTERMSIG(pstat)),
|
|
|
|
WCOREDUMP(pstat) ? "; core dumped" : "");
|
|
|
|
if (nf)
|
|
|
|
FREE_SPACE(sp, p, 0);
|
|
|
|
return (1);
|
|
|
|
}
|
1994-01-24 08:52:58 +03:00
|
|
|
|
1996-05-20 07:47:00 +04:00
|
|
|
if (WIFEXITED(pstat) && WEXITSTATUS(pstat)) {
|
|
|
|
/*
|
|
|
|
* Remain silent for "normal" errors when doing shell file
|
|
|
|
* name expansions, they almost certainly indicate nothing
|
|
|
|
* more than a failure to match.
|
|
|
|
*
|
|
|
|
* Remain silent for vi read filter errors. It's historic
|
|
|
|
* practice.
|
|
|
|
*/
|
|
|
|
if (!silent) {
|
|
|
|
for (; isblank(*cmd); ++cmd);
|
|
|
|
p = msg_print(sp, cmd, &nf);
|
|
|
|
len = strlen(p);
|
|
|
|
msgq(sp, M_ERR, "%.*s%s: exited with status %d",
|
2001-05-01 20:46:11 +04:00
|
|
|
(int) MIN(len, 20), p, len > 20 ? " ..." : "",
|
1996-05-20 07:47:00 +04:00
|
|
|
WEXITSTATUS(pstat));
|
|
|
|
if (nf)
|
|
|
|
FREE_SPACE(sp, p, 0);
|
|
|
|
}
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX
|
|
|
|
* The sys_siglist[] table in the C library has this information, but there's
|
|
|
|
* no portable way to get to it. (Believe me, I tried.)
|
|
|
|
*/
|
|
|
|
typedef struct _sigs {
|
|
|
|
int number; /* signal number */
|
|
|
|
char *message; /* related message */
|
|
|
|
} SIGS;
|
|
|
|
|
|
|
|
SIGS const sigs[] = {
|
|
|
|
#ifdef SIGABRT
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGABRT, "Abort trap" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SIGALRM
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGALRM, "Alarm clock" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SIGBUS
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGBUS, "Bus error" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SIGCLD
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGCLD, "Child exited or stopped" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SIGCHLD
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGCHLD, "Child exited" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SIGCONT
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGCONT, "Continued" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SIGDANGER
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGDANGER, "System crash imminent" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SIGEMT
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGEMT, "EMT trap" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SIGFPE
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGFPE, "Floating point exception" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SIGGRANT
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGGRANT, "HFT monitor mode granted" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SIGHUP
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGHUP, "Hangup" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SIGILL
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGILL, "Illegal instruction" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SIGINFO
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGINFO, "Information request" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SIGINT
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGINT, "Interrupt" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SIGIO
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGIO, "I/O possible" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SIGIOT
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGIOT, "IOT trap" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SIGKILL
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGKILL, "Killed" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SIGLOST
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGLOST, "Record lock" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SIGMIGRATE
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGMIGRATE, "Migrate process to another CPU" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SIGMSG
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGMSG, "HFT input data pending" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SIGPIPE
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGPIPE, "Broken pipe" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SIGPOLL
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGPOLL, "I/O possible" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SIGPRE
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGPRE, "Programming error" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SIGPROF
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGPROF, "Profiling timer expired" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SIGPWR
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGPWR, "Power failure imminent" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SIGRETRACT
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGRETRACT, "HFT monitor mode retracted" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SIGQUIT
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGQUIT, "Quit" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SIGSAK
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGSAK, "Secure Attention Key" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SIGSEGV
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGSEGV, "Segmentation fault" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SIGSOUND
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGSOUND, "HFT sound sequence completed" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SIGSTOP
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGSTOP, "Suspended (signal)" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SIGSYS
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGSYS, "Bad system call" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SIGTERM
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGTERM, "Terminated" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SIGTRAP
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGTRAP, "Trace/BPT trap" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SIGTSTP
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGTSTP, "Suspended" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SIGTTIN
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGTTIN, "Stopped (tty input)" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SIGTTOU
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGTTOU, "Stopped (tty output)" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SIGURG
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGURG, "Urgent I/O condition" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SIGUSR1
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGUSR1, "User defined signal 1" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SIGUSR2
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGUSR2, "User defined signal 2" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SIGVTALRM
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGVTALRM, "Virtual timer expired" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SIGWINCH
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGWINCH, "Window size changes" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SIGXCPU
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGXCPU, "Cputime limit exceeded" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SIGXFSZ
|
2001-05-01 20:46:11 +04:00
|
|
|
{ SIGXFSZ, "Filesize limit exceeded" },
|
1996-05-20 07:47:00 +04:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* sigmsg --
|
|
|
|
* Return a pointer to a message describing a signal.
|
|
|
|
*/
|
|
|
|
static const char *
|
|
|
|
sigmsg(signo)
|
|
|
|
int signo;
|
|
|
|
{
|
|
|
|
static char buf[40];
|
|
|
|
const SIGS *sigp;
|
|
|
|
int n;
|
|
|
|
|
|
|
|
for (n = 0,
|
|
|
|
sigp = &sigs[0]; n < sizeof(sigs) / sizeof(sigs[0]); ++n, ++sigp)
|
|
|
|
if (sigp->number == signo)
|
|
|
|
return (sigp->message);
|
|
|
|
(void)snprintf(buf, sizeof(buf), "Unknown signal: %d", signo);
|
|
|
|
return (buf);
|
1994-01-24 08:52:58 +03:00
|
|
|
}
|