summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2011-01-30 22:57:52 +0000
committerjilles <jilles@FreeBSD.org>2011-01-30 22:57:52 +0000
commit8605caacbf4653c0daaaf53f746ae27fc93c1ef3 (patch)
tree9cd99b27d5c80c0459825016362a1e655635936a
parent3ee570eed2eb50450d95f20db6719eeb5d5ba3e6 (diff)
downloadFreeBSD-src-8605caacbf4653c0daaaf53f746ae27fc93c1ef3.zip
FreeBSD-src-8605caacbf4653c0daaaf53f746ae27fc93c1ef3.tar.gz
sh: Send messages about signals to stderr.
This is required by POSIX and seems to make more sense. See also r217557.
-rw-r--r--bin/sh/jobs.c10
-rw-r--r--tools/regression/bin/sh/execution/killed2.010
2 files changed, 15 insertions, 5 deletions
diff --git a/bin/sh/jobs.c b/bin/sh/jobs.c
index ea8c8f8..7ffdc2a 100644
--- a/bin/sh/jobs.c
+++ b/bin/sh/jobs.c
@@ -1056,13 +1056,13 @@ dowait(int block, struct job *job)
}
if (sig > 0 && sig != SIGINT && sig != SIGPIPE) {
if (sig < sys_nsig && sys_siglist[sig])
- out1str(sys_siglist[sig]);
+ out2str(sys_siglist[sig]);
else
- out1fmt("Signal %d", sig);
+ outfmt(out2, "Signal %d", sig);
if (coredump)
- out1str(" (core dumped)");
- out1c('\n');
- flushout(out1);
+ out2str(" (core dumped)");
+ out2c('\n');
+ flushout(out2);
}
} else {
TRACE(("Not printing status, rootshell=%d, job=%p\n", rootshell, job));
diff --git a/tools/regression/bin/sh/execution/killed2.0 b/tools/regression/bin/sh/execution/killed2.0
new file mode 100644
index 0000000..7ff3fe2
--- /dev/null
+++ b/tools/regression/bin/sh/execution/killed2.0
@@ -0,0 +1,10 @@
+# $FreeBSD$
+# Most shells print a message when a foreground job is killed by a signal.
+# POSIX allows this, provided the message is sent to stderr, not stdout.
+# Some trickery is needed to capture the message as redirecting stderr of
+# the command itself does not affect it. The colon command ensures that
+# the subshell forks for ${SH}.
+
+exec 3>&1
+r=`(${SH} -c 'kill $$'; :) 2>&1 >&3`
+[ -n "$r" ]
OpenPOWER on IntegriCloud