From 0a805819559aedf0eeac98ae07fa46cab047fb99 Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Thu, 6 Sep 2007 19:57:48 +0000 Subject: Be more smart waiting for input for non-interactive scripts. Fix based on a diff from debian: see their bug#296446. ok millert@ sobrado@ --- bin/ksh/jobs.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/bin/ksh/jobs.c b/bin/ksh/jobs.c index 05d9d2a6ef4..53f58b5e4d2 100644 --- a/bin/ksh/jobs.c +++ b/bin/ksh/jobs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: jobs.c,v 1.35 2006/02/06 16:47:07 jmc Exp $ */ +/* $OpenBSD: jobs.c,v 1.36 2007/09/06 19:57:47 otto Exp $ */ /* * Process and job control @@ -246,11 +246,17 @@ j_change(void) int i; if (Flag(FMONITOR)) { - /* Don't call tcgetattr() 'til we own the tty process group */ - tty_init(false); + int use_tty; + + if (Flag(FTALKING)) { + /* Don't call tcgetattr() 'til we own the tty process group */ + use_tty = 1; + tty_init(false); + } else + use_tty = 0; /* no controlling tty, no SIGT* */ - ttypgrp_ok = tty_fd >= 0 && tty_devtty; + ttypgrp_ok = use_tty && tty_fd >= 0 && tty_devtty; if (ttypgrp_ok && (our_pgrp = getpgrp()) < 0) { warningf(false, "j_init: getpgrp() failed: %s", @@ -296,8 +302,10 @@ j_change(void) our_pgrp = kshpid; } } - if (!ttypgrp_ok) - warningf(false, "warning: won't have full job control"); + if (use_tty) { + if (!ttypgrp_ok) + warningf(false, "warning: won't have full job control"); + } if (tty_fd >= 0) tcgetattr(tty_fd, &tty_state); } else { -- cgit v1.2.3