zsh-users
 help / color / mirror / code / Atom feed
* kill % fails?
@ 2021-11-26 18:20 Dominik Vogt
  2021-11-27 20:28 ` Bart Schaefer
  0 siblings, 1 reply; 6+ messages in thread
From: Dominik Vogt @ 2021-11-26 18:20 UTC (permalink / raw)
  To: Zsh Users

Why does this not kill all processes?

 $ killall xeyes
 $ pstree | grep xeyes
 # no xeyes running
 $ for i in $(seq 1000); do xeyes & sleep 0.01; kill %; done
 zsh: job table full
 [2]    terminated  xeyes
 [3]    terminated  xeyes
 ...
 [996]    terminated  xeyes
 [997]  - terminated  xeyes
 $ pstree | grep xeyes
        |                          `-xeyes(28266)     <----- not killed?
 $ killall xeyes
 $ pstree | grep xeyes
 [998]  + terminated  xeyes

Okay, I understand that bit about the full job table, but why is
the last process not killed?

Note: The 0.01 second sleep is just long enough so that xeyes
tries to create a window on my system.

Warning: If not running fvwm as a window manager, you wm may well
go crazy, crash or become busy for a long time.  Better save your
work first.

Ciao

Dominik ^_^  ^_^

--

Dominik Vogt


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: kill % fails?
  2021-11-26 18:20 kill % fails? Dominik Vogt
@ 2021-11-27 20:28 ` Bart Schaefer
  2021-11-28  1:31   ` Dominik Vogt
  0 siblings, 1 reply; 6+ messages in thread
From: Bart Schaefer @ 2021-11-27 20:28 UTC (permalink / raw)
  To: dominik.vogt, Zsh Users

On Fri, Nov 26, 2021 at 10:21 AM Dominik Vogt <dominik.vogt@gmx.de> wrote:
>
> Okay, I understand that bit about the full job table, but why is
> the last process not killed?

I believe it's because the "sleep" is the job for which there is no
room in the job table, so the whole loop aborts before reaching the
"kill" for the last time.  If this were not the case you'd see the
error message two or three times.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: kill % fails?
  2021-11-27 20:28 ` Bart Schaefer
@ 2021-11-28  1:31   ` Dominik Vogt
  2021-11-28  2:15     ` Bart Schaefer
  0 siblings, 1 reply; 6+ messages in thread
From: Dominik Vogt @ 2021-11-28  1:31 UTC (permalink / raw)
  To: Zsh Users

On Sat, Nov 27, 2021 at 12:28:10PM -0800, Bart Schaefer wrote:
> On Fri, Nov 26, 2021 at 10:21 AM Dominik Vogt <dominik.vogt@gmx.de> wrote:
> >
> > Okay, I understand that bit about the full job table, but why is
> > the last process not killed?
>
> I believe it's because the "sleep" is the job for which there is no
> room in the job table, so the whole loop aborts before reaching the
> "kill" for the last time.  If this were not the case you'd see the
> error message two or three times.

I thought only the background processes woul be put in the job
table?  Is there a way to print the command that could not be
added?

Ciao

Dominik ^_^  ^_^

--

Dominik Vogt


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: kill % fails?
  2021-11-28  1:31   ` Dominik Vogt
@ 2021-11-28  2:15     ` Bart Schaefer
  2021-11-28  9:49       ` Dominik Vogt
  0 siblings, 1 reply; 6+ messages in thread
From: Bart Schaefer @ 2021-11-28  2:15 UTC (permalink / raw)
  To: dominik.vogt, Zsh Users

On Sat, Nov 27, 2021 at 5:32 PM Dominik Vogt <dominik.vogt@gmx.de> wrote:
>
> I thought only the background processes woul be put in the job
> table?

No ... the "for" loop and each of the foreground commands also have
job table entries, to permit ^Z/bg/fg management.  That's why you get
a full job table after 998 background jobs instead of 1000.

> Is there a way to print the command that could not be
> added?

Run with xtrace enabled?

For what it's worth, if you "setopt notify" (or rather, avoid "setopt
nonotify" which you must be getting from "sh" emulation?) you won't
fill the job table.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: kill % fails?
  2021-11-28  2:15     ` Bart Schaefer
@ 2021-11-28  9:49       ` Dominik Vogt
  2021-11-28 20:10         ` Bart Schaefer
  0 siblings, 1 reply; 6+ messages in thread
From: Dominik Vogt @ 2021-11-28  9:49 UTC (permalink / raw)
  To: Zsh Users

On Sat, Nov 27, 2021 at 06:15:32PM -0800, Bart Schaefer wrote:
> On Sat, Nov 27, 2021 at 5:32 PM Dominik Vogt <dominik.vogt@gmx.de> wrote:
> No ... the "for" loop and each of the foreground commands also have
> job table entries, to permit ^Z/bg/fg management.  That's why you get
> a full job table after 998 background jobs instead of 1000.
>
> > Is there a way to print the command that could not be
> > added?
>
> Run with xtrace enabled?

It prints the whole block inside the loop, but nevermind, I just
wanted to rule out that the window manager has any part in that.

> For what it's worth, if you "setopt notify" (or rather, avoid "setopt
> nonotify" which you must be getting from "sh" emulation?)

For whatever reason, there was "unsetopt notify" in zshrc.

> you won't fill the job table.

Yup, thanks, that helps.

Ciao

Dominik ^_^  ^_^

--

Dominik Vogt


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: kill % fails?
  2021-11-28  9:49       ` Dominik Vogt
@ 2021-11-28 20:10         ` Bart Schaefer
  0 siblings, 0 replies; 6+ messages in thread
From: Bart Schaefer @ 2021-11-28 20:10 UTC (permalink / raw)
  To: dominik.vogt, Zsh Users

On Sun, Nov 28, 2021 at 1:50 AM Dominik Vogt <dominik.vogt@gmx.de> wrote:
>
> > Run with xtrace enabled?
>
> It prints the whole block inside the loop

Hmm.  I used
%  for i in {1000..1}; do /bin/sleep $i & sleep 0.01; kill %; done

and I get as the last two iterations

+Src/zsh:12> i=5
[997] 64582
+Src/zsh:12> /bin/sleep 5
+Src/zsh:12> sleep 0.01
+Src/zsh:12> kill %
+Src/zsh:12> i=4
[998] 64584
zsh: job table full
+Src/zsh:12> /bin/sleep 4

So that looks to me as though the background "/bin/sleep 4" fills the
table and the foreground sleep fails and kills the loop.  The loop is
%1 and the first background job is %2 ...


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-11-28 20:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-26 18:20 kill % fails? Dominik Vogt
2021-11-27 20:28 ` Bart Schaefer
2021-11-28  1:31   ` Dominik Vogt
2021-11-28  2:15     ` Bart Schaefer
2021-11-28  9:49       ` Dominik Vogt
2021-11-28 20:10         ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).