Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Functions that start Jobs

On Jun 29,  1:04am, Gregory Margo wrote:
} Why does a function take up a job slot?

Because you can suspend it with ^Z, and at that point it does become a
separate job that appears in the "jobs" output.


zagzig% foo() { sleep 30 & sleep 10 }
zagzig% foo
[2] 13882
zsh: suspended  foo
zagzig% jobs
[1]  + suspended  foo
[2]  - running    sleep 30

} And if it does, why doesn't 'exec' work?

If you mean what I think you mean, then the reason is that 'exec' deals
with processes -- it makes a new process replace the old process.  But
job table entries are not processes; they're just zsh's internal method
of doing record-keeping for commands in progress.

Loops take up a job table slot too:

zagzig% jobs
zagzig% repeat 2 do sleep 5 & done
[2] 13890
[3] 13891

Here "repeat ..." is job 1, so the backgrounded sleeps become 2 and 3.

Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   

Messages sorted by: Reverse Date, Date, Thread, Author