ksh script leaving 'running jobs' that aren't

ksh script leaving 'running jobs' that aren't

Post by Kevin Farra » Fri, 07 Jun 1996 04:00:00



What makes the . command behave this way? Please share some "dot" wisdom
with a fellow shell programmer.

I am trying to do some PATH manipulation in a ksh function that gets
defined by .profile. The problem is that my function leaves running jobs
that are not really running.  I cannot exit the shell without taking
care of these things.  I have read all I can find on ksh and the .
command but I still do not understand why I get this.

Short and sweet 1 line example you can try yourself;
  (file called try.ksh)

Quote:> cat try.ksh

echo "start" | grep "a"
Quote:

> try.ksh

start                  { works fine }
Quote:> jobs
>                      { no jobs running right? }
> . try.ksh

start                  { again works fine }
Quote:

> jobs

[1] +  Done                    . try.ksh

There it is!  Its 'Done' but it won't go away until I run jobs or some
other attempt to find out why it is still around.

I have tried sed, cut, and a few other methods to test for a duplicate
string but this seems to be the cleanest.

----- snip from actual script -------------------------
# Eliminate duplicates in PATH
# No longer want to rely on pathuniq due to it's perl dependency
#
NewPath=":"
#

do

  # Have we added this path before?
  echo $NewPath | \grep ":${PathElem}:"  > /dev/null  
  [ $? -eq 0 ] && continue
  # Append this Path element to New path
    NewPath="${NewPath}${PathElem}:"

done

NewPath="${NewPath}:"
NewPath=`echo $NewPath | sed "s?::??g"`


----------- end of snip -------------------------------

========================================================================

Product Development Engineer                Phone:         (513)576-2400
Structural Dynamics Research Corp.          Ext:                   x2479
2000 Eastman Drive                          Fax:           (513)576-7591
Milford OH 45150                            Web:    http://www.sdrc.com/
========================================================================
                I fight entropy, but entropy always wins.             O-
------------------------------------------------------------------------

 
 
 

ksh script leaving 'running jobs' that aren't

Post by Brian S Hil » Sun, 09 Jun 1996 04:00:00


: What makes the . command behave this way? Please share some "dot" wisdom
: with a fellow shell programmer.
: I am trying to do some PATH manipulation in a ksh function that gets
: defined by .profile. The problem is that my function leaves running jobs
: that are not really running.  I cannot exit the shell without taking
: care of these things.  I have read all I can find on ksh and the .
: command but I still do not understand why I get this.
: Short and sweet 1 line example you can try yourself;
:   (file called try.ksh)
: > cat try.ksh
: echo "start" | grep "a"
: >
: > try.ksh
: start                  { works fine }
: > jobs
: >                      { no jobs running right? }
: > . try.ksh
: start                  { again works fine }
: >
: > jobs
: [1] +  Done                    . try.ksh
: >
: There it is!  Its 'Done' but it won't go away until I run jobs or some
: other attempt to find out why it is still around.
: I have tried sed, cut, and a few other methods to test for a duplicate
: string but this seems to be the cleanest.

: ----- snip from actual script -------------------------
: # Eliminate duplicates in PATH
: # No longer want to rely on pathuniq due to it's perl dependency
: #
: NewPath=":"
: #

: do
:   # Have we added this path before?
:   echo $NewPath | \grep ":${PathElem}:"  > /dev/null  
:   [ $? -eq 0 ] && continue
:   # Append this Path element to New path
:     NewPath="${NewPath}${PathElem}:"

: NewPath="${NewPath}:"
: NewPath=`echo $NewPath | sed "s?::??g"`

: ----------- end of snip -------------------------------

The "monitor" option (whereby an the shell associates a job number with each
pipeline), automatically set by an interactive shell, will "block" until
recognized by the user via a "jobs" command. This, I feel, is a mis-feature,
one that I overcome by using the command "jobs >&-" or "set +o monitor".

-Brian

Man page lines:

     when the monitor option of the set command is turned on, an interactive
     shell associates a job with each pipeline.

     ... monitor mode is on, each background job that completes triggers
     any trap set for CHLD.

--
   ,---.     ,---.     ,---.     ,---.     ,---.     ,---.     ,---.  
  /  _  \   /  _  \   /  _  \   /  _  \   /  _  \   /  _  \   /  _  \  

__,'   `.___,'   `.___,'   `.___,'   `.___,'   `.___,'   `.___,'   `.__

 
 
 

1. why aren't 'esc' ~ 'break' recognized?

That's the expected behaviour of the ESCape key under UNIX terminal
applications.  Changing it would break many programs (anything using
emacs or vi editing keystrokes for a start).

Why do you think it should be "a break"?  And what do you mean by "a
break" anyway?

--
________________________________________________________________________

Univ. of California at Berkeley         http://soar.Berkeley.EDU/~alanc/

2. pinging and DNS

3. posix/ksh: Constants aren't; Variables won't

4. problems (minor) with KDE 3.1

5. 'sh' script spawning Sun 'cmdtool' running program

6. I'me getting modem madness!

7. cron jobs aren't running :-(

8. Map Plotting in Linux?

9. 'at' runs job, cron doesn't!

10. OS5 'All licenses are in use' but aren't

11. 'script' in a cron initiated ksh script

12. 'su --login user -c command' doesn't run loggin scripts

13. ksh: trap '...' exit int ... or just trap '...' exit?