Create own bsd_signal() stub.

diff --git a/ash/Makefile b/ash/Makefile
index 5fc5912..0f55e22 100644
--- a/ash/Makefile
+++ b/ash/Makefile
@@ -1,5 +1,3 @@
-#	Makefile,v 1.7 1993/08/09 04:58:18 mycroft Exp
-
 PROG=	sh
 SRCS=	builtins.c cd.c dirent.c bltin/echo.c error.c eval.c exec.c expand.c \
 	input.c jobs.c mail.c main.c memalloc.c miscbltin.c \
@@ -26,7 +24,7 @@
 
 HOST_CC      = gcc
 HOST_CFLAGS  = -g -I. -DSHELL
-HOST_LDFLAGS = -s
+HOST_LDFLAGS =
 HOST_LIBS    =
 
 CLEANFILES =\
diff --git a/ash/main.c b/ash/main.c
index 704254c..8b3b5b0 100644
--- a/ash/main.c
+++ b/ash/main.c
@@ -105,7 +105,7 @@
 	monitor(4, etext, profile_buf, sizeof profile_buf, 50);
 #endif
 #ifdef linux
-	signal(SIGCHLD,SIG_DFL);
+	bsd_signal(SIGCHLD,SIG_DFL);
 #endif /* linux */
 	state = 0;
 	if (setjmp(jmploc.loc)) {
diff --git a/ash/redir.c b/ash/redir.c
index c210524..24c4cea 100644
--- a/ash/redir.c
+++ b/ash/redir.c
@@ -231,13 +231,13 @@
 	}
 	if (forkshell((struct job *)NULL, (union node *)NULL, FORK_NOJOB) == 0) {
 		close(pip[0]);
-		signal(SIGINT, SIG_IGN);
-		signal(SIGQUIT, SIG_IGN);
-		signal(SIGHUP, SIG_IGN);
+		bsd_signal(SIGINT, SIG_IGN);
+		bsd_signal(SIGQUIT, SIG_IGN);
+		bsd_signal(SIGHUP, SIG_IGN);
 #ifdef SIGTSTP
-		signal(SIGTSTP, SIG_IGN);
+		bsd_signal(SIGTSTP, SIG_IGN);
 #endif
-		signal(SIGPIPE, SIG_DFL);
+		bsd_signal(SIGPIPE, SIG_DFL);
 		if (redir->type == NHERE)
 			xwrite(pip[1], redir->nhere.doc->narg.text, len);
 		else
diff --git a/ash/trap.c b/ash/trap.c
index 09f619e..f36c1b0 100644
--- a/ash/trap.c
+++ b/ash/trap.c
@@ -188,7 +188,7 @@
 		 * There is a race condition here if action is not S_IGN.
 		 * A signal can be ignored that shouldn't be.
 		 */
-		if ((int)(sigact = signal(signo, SIG_IGN)) == -1)
+		if ((int)(sigact = bsd_signal(signo, SIG_IGN)) == -1)
 			error("Signal system call failed");
 		if (sigact == SIG_IGN) {
 			*t = S_HARD_IGN;
@@ -204,7 +204,7 @@
 		case S_IGN:	sigact = SIG_IGN;	break;
 	}
 	*t = action;
-	return (int)signal(signo, sigact);
+	return (int)bsd_signal(signo, sigact);
 }
 
 
@@ -215,7 +215,7 @@
 void
 ignoresig(signo) {
 	if (sigmode[signo] != S_IGN && sigmode[signo] != S_HARD_IGN) {
-		signal(signo, SIG_IGN);
+		bsd_signal(signo, SIG_IGN);
 	}
 	sigmode[signo] = S_HARD_IGN;
 }
@@ -244,7 +244,7 @@
 
 void
 onsig(signo) {
-	signal(signo, onsig);
+	bsd_signal(signo, onsig);
 	if (signo == SIGINT && trap[SIGINT] == NULL) {
 		onint();
 		return;
@@ -325,3 +325,19 @@
 #endif
 l2:   _exit(status);
 }
+
+/*
+ * Emulation of the BSD signal() call
+ */
+__sighandler_t bsd_signal(int signum, __sighandler_t handler)
+{
+  struct sigaction act;
+  int rv;
+
+  memset(&act, 0, sizeof act);
+  act.sa_handler = handler;
+  act.sa_flags   = SA_RESTART;
+  
+  return sigaction(signum, &act, &act)
+    ? SIG_ERR : act.sa_handler;
+}
diff --git a/ash/trap.h b/ash/trap.h
index 16e8d87..a7d18d2 100644
--- a/ash/trap.h
+++ b/ash/trap.h
@@ -37,6 +37,8 @@
  *	trap.h,v 1.4 1993/08/01 18:58:34 mycroft Exp
  */
 
+#include <signal.h>
+
 extern int pendingsigs;
 
 #ifdef __STDC__
@@ -46,6 +48,7 @@
 void dotrap(void);
 void setinteractive(int);
 void exitshell(int);
+__sighandler_t bsd_signal(int, __sighandler_t);
 #else
 void clear_traps();
 int setsignal();