tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
* ksh, .profile, exec, and default .profile
@ 2003-01-04 20:08 charter
  0 siblings, 0 replies; only message in thread
From: charter @ 2003-01-04 20:08 UTC (permalink / raw)


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







^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-01-04 20:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-04 20:08 ksh, .profile, exec, and default .profile charter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox