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

PATCH: Re: disowning stopped jobs



Bart Schaefer wrote:

> On Jun 25, 11:00am, Sven Wischnowsky wrote:
> } Subject: disowning stopped jobs
> }
> } Maybe we can `solve' (or, rather, circumvent) this problem by being more
> } verbose, saying `warning: job is stopped, use `kill -CONT ...' to resume'.
> } That way, users can even use cut&paste to make the job running.
> } 
> } Any better wording?  Should we print the `kill ...' indented on its own
> } line?
> 
> I think it's OK as it is, at least until we get some empirical feedback.

Fine, I'm going to commit it to the development branch, should it go
into 4.0.2, too?

> What about my other suggestion, that `%job &!' should use `bg' and then
> handle the job table in exec.c ?

I looked into this shortly, it would require us to export getjob() and
then should be relatively simple.  But.  Just had an idea.  Why not give
an option to disown, say `-c' for `continue', that makes it wake up
stopped jobs before disowning them?  With that, users could alias
`disown' to `disown -c' to never have to worry about that anymore and in
execcmd() we just would have to stick the `-c' into the list.


Bye
  Sven

Index: Src/jobs.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/jobs.c,v
retrieving revision 1.11
diff -u -r1.11 jobs.c
--- Src/jobs.c	2001/05/29 09:49:58	1.11
+++ Src/jobs.c	2001/06/26 08:12:37
@@ -1392,14 +1392,36 @@
 	    printjob(job + jobtab, lng, 2);
 	    break;
 	case BIN_DISOWN:
-	    if (jobtab[job].stat & STAT_STOPPED)
+	    if (jobtab[job].stat & STAT_STOPPED) {
+		char buf[20], *pids = "";
+
+		if (jobtab[job].stat & STAT_SUPERJOB) {
+		    Process pn;
+
+		    for (pn = jobtab[jobtab[job].other].procs; pn; pn = pn->next) {
+			sprintf(buf, " -%d", pn->pid);
+			pids = dyncat(pids, buf);
+		    }
+		    for (pn = jobtab[job].procs; pn->next; pn = pn->next) {
+			sprintf(buf, " %d", pn->pid);
+			pids = dyncat(pids, buf);
+		    }
+		    if (!jobtab[jobtab[job].other].procs && pn) {
+			sprintf(buf, " %d", pn->pid);
+			pids = dyncat(pids, buf);
+		    }
+		} else {
+		    sprintf(buf, " -%d", jobtab[job].gleader);
+		    pids = buf;
+		}
                 zwarnnam(name,
 #ifdef USE_SUSPENDED
-                         "warning: job is suspended",
+                         "warning: job is suspended, use `kill -CONT%s' to resume",
 #else
-                         "warning: job is stopped",
+                         "warning: job is stopped, use `kill -CONT%s' to resume",
 #endif
-                         NULL, 0);
+                         pids, 0);
+	    }
 	    deletejob(jobtab + job);
 	    break;
 	}

-- 
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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