From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: charter Newsgroups: gmane.os.tru64.managers Subject: ksh, .profile, exec, and default .profile Date: Sat, 04 Jan 2003 14:08:23 -0600 Sender: tru64-unix-managers-owner@ornl.gov Message-ID: <002501c2b42d$091def80$0200a8c0@adam2> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 7bit X-Trace: main.gmane.org 1041710863 473 80.91.224.249 (4 Jan 2003 20:07:43 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sat, 4 Jan 2003 20:07:43 +0000 (UTC) Return-path: Original-Received: from sws1.ctd.ornl.gov ([160.91.20.101]) by main.gmane.org with smtp (Exim 3.35 #1 (Debian)) id 18Uua5-00007G-00 for ; Sat, 04 Jan 2003 21:07:41 +0100 Original-Received: (qmail 11785 invoked by uid 5); 4 Jan 2003 20:08:22 -0000 Original-Followup-To: poster Precedence: bulk Original-Received: (qmail 11764 invoked by uid 49493); 4 Jan 2003 20:08:21 -0000 Original-Received: from ajgarsha1@charter.net by sws1 by uid 49491 with qmail-scanner-1.14 (clamscan: 0.54. spamassassin: 2.50-cvs. Clear:SA:0(1.0/5.0):. Processed in 0.385268 secs); 04 Jan 2003 20:08:21 -0000 Original-Received: from unknown (HELO emroute2.cind.ornl.gov) (128.219.159.41) by 0 with SMTP; 4 Jan 2003 20:08:21 -0000 Original-Received: from emroute2.cind.ornl.gov (LOCALHOST [127.0.0.1]) by emroute2.cind.ornl.gov (PMDF V6.1-1 #39060) with ESMTP id <0H8700D0DH9WCO@emroute2.cind.ornl.gov> for tru64-unix-managers@sws1.ctd.ornl.gov (ORCPT tru64-unix-managers@ornl.gov) ; Sat, 04 Jan 2003 15:08:21 -0500 (EST) Original-Received: from dc-mx13.cluster1.charter.net (dc-mx13.cluster1.charter.net [209.225.8.23]) by emroute2.cind.ornl.gov (PMDF V6.1-1 #39060) with ESMTP id <0H87009BFH8WXB@emroute2.cind.ornl.gov> for tru64-unix-managers@sws1.ctd.ornl.gov (ORCPT tru64-unix-managers@ornl.gov) ; Sat, 04 Jan 2003 15:07:50 -0500 (EST) Original-Received: from [66.188.103.63] (HELO adam2) by dc-mx13.cluster1.charter.net (CommuniGate Pro SMTP 3.5.9) with SMTP id 26935665 for tru64-unix-managers@ornl.gov; Sat, 04 Jan 2003 15:07:43 -0500 Original-To: tru64-unix-managers@ornl.gov X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-Priority: 3 X-MSMail-priority: Normal Xref: main.gmane.org gmane.os.tru64.managers:2847 X-Report-Spam: http://spam.gmane.org/gmane.os.tru64.managers:2847 Tested on Tru64 5.1. Users are forced into an application by an exec command placed in their ksh shell's .profile. The .profile files are the default with an "exec /some/path/foo" command and an "exit" added at the end. Problem: I noticed on occasion that users would be troubled with immediate disconnects after authentication. The disconnect would occur at the "exec" line with a message: "You have running jobs". Trial and error and employing "set -x", "jobs -l", etc. against .profile files leads me to this boiled down example of a .profile that will reproduce the problem: #start of .profile sleep 5 & exec ./foo exit #end of .profile The above snippet mirrors the failure that you get from: #start of default .profile #... some stuff echo $PATH | /bin/grep -q "$HOME/bin" || { PATH=$HOME/bin:${PATH:-/usr/bin:.} export PATH } exec ./foo exit #end of .profile Namely, the echo and grep command are still hanging about as background jobs when the exec command is attempted... for reasons that I am unsure of... this causes the exec command to fail for login shells. If you put a "sleep 1" after the PATH block, the race condition seems to go away (echo and grep have time to die) and the exec is always successful. Work arounds are easy. I am curious if anyone understands why this is the case for login shells, i.e. why does exec fail if background procs exist? Further why are echo and grep "hanging around"--shouldn't they be dead and gone by the time the exec call is attempted? ajgarsha1@charter.net