zsh-workers
 help / color / mirror / code / Atom feed
* jobs -r doesn't show jobs continued by kill -CONT
@ 2015-05-03 22:52 Han Pingtian
  2015-05-04  6:26 ` Bart Schaefer
  2015-05-04 17:36 ` Peter Stephenson
  0 siblings, 2 replies; 5+ messages in thread
From: Han Pingtian @ 2015-05-03 22:52 UTC (permalink / raw)
  To: zsh-workers

Hi,

jobs -r doesn't show a job which suspended the continued by kill -CONT:

% zsh -f
localhost% sleep 50
^Z
zsh: suspended  sleep 50
localhost% jobs -r
localhost% jobs
[1]  + suspended  sleep 50
localhost% kill -CONT %1
localhost% jobs
[1]  + running    sleep 50
localhost% jobs -r
localhost% 

If the job was continued by bg, then job -r can show it.


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

* Re: jobs -r doesn't show jobs continued by kill -CONT
  2015-05-03 22:52 jobs -r doesn't show jobs continued by kill -CONT Han Pingtian
@ 2015-05-04  6:26 ` Bart Schaefer
  2015-05-04 17:36 ` Peter Stephenson
  1 sibling, 0 replies; 5+ messages in thread
From: Bart Schaefer @ 2015-05-04  6:26 UTC (permalink / raw)
  To: Zsh hackers list

On Sun, May 3, 2015 at 3:52 PM, Han Pingtian <hanpt@linux.vnet.ibm.com> wrote:
>
> jobs -r doesn't show a job which suspended [then] continued by kill -CONT

Similarly, "jobs -s" continues to list those jobs.  The status shown
by "jobs" changes as follows:

^Z --> suspended
CONT --> running
bg --> continued


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

* Re: jobs -r doesn't show jobs continued by kill -CONT
  2015-05-03 22:52 jobs -r doesn't show jobs continued by kill -CONT Han Pingtian
  2015-05-04  6:26 ` Bart Schaefer
@ 2015-05-04 17:36 ` Peter Stephenson
  2015-05-05 19:02   ` Bart Schaefer
  1 sibling, 1 reply; 5+ messages in thread
From: Peter Stephenson @ 2015-05-04 17:36 UTC (permalink / raw)
  To: zsh-workers

On Mon, 4 May 2015 06:52:13 +0800
Han Pingtian <hanpt@linux.vnet.ibm.com> wrote:
> jobs -r doesn't show a job which suspended the continued by kill -CONT:

Not sure whether to use makerunning() here.  It's handled per process
rather than per job at this point, so it's not entirely clear at what
point the STAT_STOPPED flag should be removed, either.

pws

diff --git a/Src/jobs.c b/Src/jobs.c
index 295f4c9..948f61b 100644
--- a/Src/jobs.c
+++ b/Src/jobs.c
@@ -421,8 +421,10 @@ update_job(Job jn)
 
     for (pn = jn->procs; pn; pn = pn->next) {
 #ifdef WIFCONTINUED
-	if (WIFCONTINUED(pn->status))
+	if (WIFCONTINUED(pn->status)) {
+	    jn->stat &= ~STAT_STOPPED;
 	    pn->status = SP_RUNNING;
+	}
 #endif
 	if (pn->status == SP_RUNNING)      /* some processes in this job are running       */
 	    return;                        /* so no need to update job table entry         */


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

* Re: jobs -r doesn't show jobs continued by kill -CONT
  2015-05-04 17:36 ` Peter Stephenson
@ 2015-05-05 19:02   ` Bart Schaefer
  2015-05-05 19:14     ` Peter Stephenson
  0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2015-05-05 19:02 UTC (permalink / raw)
  To: zsh-workers

On May 4,  6:36pm, Peter Stephenson wrote:
} Subject: Re: jobs -r doesn't show jobs continued by kill -CONT
}
} On Mon, 4 May 2015 06:52:13 +0800
} Han Pingtian <hanpt@linux.vnet.ibm.com> wrote:
} > jobs -r doesn't show a job which suspended the continued by kill -CONT:
} 
} Not sure whether to use makerunning() here.  It's handled per process
} rather than per job at this point, so it's not entirely clear at what
} point the STAT_STOPPED flag should be removed, either.

Is there compound-command weirdness that's going to show up as a result
of changing jn->stat along with pn->status if there is more than one
process per job?

torch% sleep 50 | sleep 51 | sleep 52

zsh: suspended  sleep 50 | sleep 51 | sleep 52
torch% ps ax | grep sleep
18552 pts/3    T      0:00 sleep 50
18553 pts/3    T      0:00 sleep 51
18554 pts/3    T      0:00 sleep 52
18556 pts/3    S+     0:00 grep sleep
torch% kill -CONT 18553
torch% jobs
[1]  + suspended  sleep 50 | 
       running    sleep 51 | 
       suspended  sleep 52
torch% jobs -s
torch% jobs -r
[1]  + suspended  sleep 50 | 
       running    sleep 51 | 
       suspended  sleep 52
torch% 

Is it really correct to treat that last one as "running" when two-thirds
of it is still stopped?

There's something else a bit odd here, but I don't know that it's fixable.

torch% sleeper() { echo sleeping; sleep 50; echo done sleeping }
torch% sleeper
torch% sleeper                                                  
sleeping
zsh: suspended  sleeper
torch% jobs -l
[1]  + 18524 suspended  sleeper
torch% kill -CONT 18524
done sleeping                                                                   
torch% ps x | grep sleep
18523 pts/3    T      0:00 sleep 50

So the function resumed but its child remained stopped.  On the other
hand if I CONT the child sleep itself, the function remains "suspended"
as far as the parent "jobs" can tell, but it wakes up and exits when it
gets the CHLD from the actual sleep timing out.

torch% sleeper
sleeping
zsh: suspended  sleeper
torch% jobs -l
[1]  + 18543 suspended  sleeper
torch% kill -CONT 18542
torch% ps ax | grep '1854[23]'
18542 pts/3    S      0:00 sleep 50
18543 pts/3    T      0:00 Src/zsh -f
torch% done sleeping

[1]  + done       sleeper
torch% 


-- 
Barton E. Schaefer


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

* Re: jobs -r doesn't show jobs continued by kill -CONT
  2015-05-05 19:02   ` Bart Schaefer
@ 2015-05-05 19:14     ` Peter Stephenson
  0 siblings, 0 replies; 5+ messages in thread
From: Peter Stephenson @ 2015-05-05 19:14 UTC (permalink / raw)
  To: zsh-workers

On Tue, 5 May 2015 12:02:14 -0700
Bart Schaefer <schaefer@brasslantern.com> wrote:
> Is there compound-command weirdness that's going to show up as a result
> of changing jn->stat along with pn->status if there is more than one
> process per job?

Yes, if only a subset of them get the SIGCONT.

Don't do that.

[Now performing the "hear no evil, see no evil, speak no evil"
ritual purification.]

pws


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

end of thread, other threads:[~2015-05-05 19:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-03 22:52 jobs -r doesn't show jobs continued by kill -CONT Han Pingtian
2015-05-04  6:26 ` Bart Schaefer
2015-05-04 17:36 ` Peter Stephenson
2015-05-05 19:02   ` Bart Schaefer
2015-05-05 19:14     ` Peter Stephenson

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).