about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorPaul Ackersviller <packersv@users.sourceforge.net>2007-05-01 03:38:08 +0000
committerPaul Ackersviller <packersv@users.sourceforge.net>2007-05-01 03:38:08 +0000
commit417a80b1e25216b2ccaf4218bcbef717fcee3469 (patch)
tree5a1b61fba2412df0f09aec9a0aef523a80aaec6c /Src
parentea04c1dbb04f66a42f92e698850f831d1e65676b (diff)
downloadzsh-417a80b1e25216b2ccaf4218bcbef717fcee3469.tar.gz
zsh-417a80b1e25216b2ccaf4218bcbef717fcee3469.tar.xz
zsh-417a80b1e25216b2ccaf4218bcbef717fcee3469.zip
Merge of workers/{20888,21296}.
Diffstat (limited to 'Src')
-rw-r--r--Src/jobs.c62
1 files changed, 38 insertions, 24 deletions
diff --git a/Src/jobs.c b/Src/jobs.c
index 5caa2fcdb..59ce7ccb5 100644
--- a/Src/jobs.c
+++ b/Src/jobs.c
@@ -1826,18 +1826,6 @@ bin_fg(char *name, char **argv, Options ops, int func)
     return retval;
 }
 
-#if defined(SIGCHLD) && defined(SIGCLD)
-#if SIGCHLD == SIGCLD
-#define ALT_SIGS 1
-#endif
-#endif
-#if defined(SIGPOLL) && defined(SIGIO)
-#if SIGPOLL == SIGIO
-#define ALT_SIGS 1
-#endif
-#endif
-
-#ifdef ALT_SIGS
 const struct {
     const char *name;
     int num;
@@ -1852,9 +1840,15 @@ const struct {
     { "IO", SIGIO },
 #endif
 #endif
+#if !defined(SIGERR)
+    /*
+     * If SIGERR is not defined by the operating system, use it
+     * as an alias for SIGZERR.
+     */
+    { "ERR", SIGZERR },
+#endif
     { NULL, 0 }
 };
-#endif
 
 /* kill: send a signal to a process.  The process(es) may be specified *
  * by job specifier (see above) or pid.  A signal, defaulting to       *
@@ -1881,10 +1875,11 @@ bin_kill(char *nam, char **argv, UNUSED(Options ops), UNUSED(int func))
 		    while (*++argv) {
 			sig = zstrtol(*argv, &signame, 10);
 			if (signame == *argv) {
+			    if (!strncmp(signame, "SIG", 3))
+				signame += 3;
 			    for (sig = 1; sig <= SIGCOUNT; sig++)
 				if (!cstrpcmp(sigs + sig, &signame))
 				    break;
-#ifdef ALT_SIGS
 			    if (sig > SIGCOUNT) {
 				int i;
 
@@ -1895,7 +1890,6 @@ bin_kill(char *nam, char **argv, UNUSED(Options ops), UNUSED(int func))
 					break;
 				    }
 			    }
-#endif
 			    if (sig > SIGCOUNT) {
 				zwarnnam(nam, "unknown signal: SIG%s",
 					 signame, 0);
@@ -1949,7 +1943,8 @@ bin_kill(char *nam, char **argv, UNUSED(Options ops), UNUSED(int func))
 		} else
 		    signame = *argv;
 		makeuppercase(&signame);
-		if (!strncmp(signame, "SIG", 3)) signame+=3;
+		if (!strncmp(signame, "SIG", 3))
+		    signame+=3;
 
 		/* check for signal matching specified name */
 		for (sig = 1; sig <= SIGCOUNT; sig++)
@@ -1957,7 +1952,6 @@ bin_kill(char *nam, char **argv, UNUSED(Options ops), UNUSED(int func))
 			break;
 		if (*signame == '0' && !signame[1])
 		    sig = 0;
-#ifdef ALT_SIGS
 		if (sig > SIGCOUNT) {
 		    int i;
 
@@ -1968,7 +1962,6 @@ bin_kill(char *nam, char **argv, UNUSED(Options ops), UNUSED(int func))
 			    break;
 			}
 		}
-#endif
 		if (sig > SIGCOUNT) {
 		    zwarnnam(nam, "unknown signal: SIG%s", signame, 0);
 		    zwarnnam(nam, "type kill -l for a List of signals", NULL, 0);
@@ -2039,22 +2032,47 @@ getsignum(char *s)
 	return x;
 
     /* search for signal by name */
+    if (!strncmp(s, "SIG", 3))
+	s += 3;
+
     for (i = 0; i < VSIGCOUNT; i++)
 	if (!strcmp(s, sigs[i]))
 	    return i;
 
-#ifdef ALT_SIGS
     for (i = 0; alt_sigs[i].name; i++)
     {
 	if (!strcmp(s, alt_sigs[i].name))
 	    return alt_sigs[i].num;
     }
-#endif
 
     /* no matching signal */
     return -1;
 }
 
+/* Get the name for a signal. */
+
+/**/
+mod_export const char *
+getsigname(int sig)
+{
+    if (sigtrapped[sig] & ZSIG_ALIAS)
+    {
+	int i;
+	for (i = 0; alt_sigs[i].name; i++)
+	    if (sig == alt_sigs[i].num)
+		return alt_sigs[i].name;
+    }
+    else
+	return sigs[sig];
+
+    /* shouldn't reach here */
+#ifdef DEBUG
+    dputs("Bad alias flag for signal");
+#endif
+    return "";
+}
+
+
 /* Get the function node for a trap, taking care about alternative names */
 /**/
 HashNode
@@ -2063,9 +2081,7 @@ gettrapnode(int sig, int ignoredisable)
     char fname[20];
     HashNode hn;
     HashNode (*getptr)(HashTable ht, char *name);
-#ifdef ALT_SIGS
     int i;
-#endif
     if (ignoredisable)
 	getptr = shfunctab->getnode2;
     else
@@ -2075,7 +2091,6 @@ gettrapnode(int sig, int ignoredisable)
     if ((hn = getptr(shfunctab, fname)))
 	return hn;
 
-#ifdef ALT_SIGS
     for (i = 0; alt_sigs[i].name; i++) {
 	if (alt_sigs[i].num == sig) {
 	    sprintf(fname, "TRAP%s", alt_sigs[i].name);
@@ -2083,7 +2098,6 @@ gettrapnode(int sig, int ignoredisable)
 		return hn;
 	}
     }
-#endif
 
     return NULL;
 }