RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1217237 - ksh misbehavior if login shell "( cmd & )" does nothing and no error reported
Summary: ksh misbehavior if login shell "( cmd & )" does nothing and no error reported
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: ksh
Version: 7.1
Hardware: All
OS: All
medium
medium
Target Milestone: rc
: ---
Assignee: Siteshwar Vashisht
QA Contact: Martin Kyral
URL:
Whiteboard:
Depends On: 1217236 1217238
Blocks: 1203710 1289025 1295829 1313485
TreeView+ depends on / blocked
 
Reported: 2015-04-29 20:29 UTC by Paulo Andrade
Modified: 2019-10-10 09:47 UTC (History)
6 users (show)

Fixed In Version: ksh-20120801-26.el7
Doc Type: Bug Fix
Doc Text:
Clone Of: 1217236
Environment:
Last Closed: 2016-11-04 07:45:58 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2016:2510 0 normal SHIPPED_LIVE ksh bug fix update 2016-11-03 14:13:51 UTC

Description Paulo Andrade 2015-04-29 20:29:50 UTC
+++ This bug was initially created as a clone of Bug #1217236 +++

To test, either have ksh as login shell, or create a test user.
Then ssh localhost.

Sample session:

---8<---
$ cd /tmp/alan
$ cat tst.ksh
#!/bin/ksh

D=$(date)
echo $D > /tmp/alan/tst.dat

$ ls
tst.ksh
$ (ksh /tmp/alan/tst.ksh &)
[1]	28190
$ ls
tst.ksh
---8<---

This happens due to a double fork, once for "( cmd )" and
then the first fork forks again due to the "&", but, just
when the child branches, it receives a SIGHUP and
immediately exits.

I tested a quick&dirty patch, that basically reverts to
rhel5 ksh behavior, and there are no regressions in the
test cases.

---8<---
diff -up ksh-20120801/src/cmd/ksh93/sh/xec.c.orig ksh-20120801/src/cmd/ksh93/sh/xec.c
--- ksh-20120801/src/cmd/ksh93/sh/xec.c.orig	2015-04-28 16:55:25.521818636 -0300
+++ ksh-20120801/src/cmd/ksh93/sh/xec.c	2015-04-28 16:56:34.037753565 -0300
@@ -2059,16 +2059,20 @@ int sh_exec(register const Shnode_t *t,
 			}
 			else if(((type=t->par.partre->tre.tretyp)&FAMP) && ((type&COMMSK)==TFORK))
 			{
+#if 0
 				pid_t	pid;
 				sfsync(NIL(Sfio_t*));
 				while((pid=fork())< 0)
 					_sh_fork(shp,pid,0,0);
 				if(pid==0)
 				{
+#endif
 					sh_exec(t->par.partre,flags);
+#if 0
 					shp->st.trapcom[0]=0;
 					sh_done(shp,0);
 				}
+#endif
 			}
 			else
 				sh_subshell(shp,t->par.partre,flags,0);
---8<---

I also asked upstream, see http://lists.research.att.com/pipermail/ast-users/2015q2/004754.html
but actually, there is a bad comment there, about crashes if
running it as "( cmd ) &". Likely it was due to the way I was
debugging it.

Note that if one has bash as login shell, then starts, or exec
ksh, or even if has ksh as login shell, and first exec ksh,
it will work, because then SIGHUP will be blocked in the
"orphan" process (orphan due to double fork).

Comment 6 errata-xmlrpc 2016-11-04 07:45:58 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2016-2510.html


Note You need to log in before you can comment on or make changes to this bug.