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

Re: background job status update



On Sat, 14 Mar 2009 10:26:18 -0700
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> The problem is that spawnjob() doesn't go through printjob() to format
> the output of "[1] 1234" (silly aside: as I was testing this, process
> IDs on my machine passed through "12345") and instead simply writes
> directly to stderr.  I think at the very least it should be using the
> special shout (shell output) file pointer, which is what printjob()
> does during all job control operations thereafter.

We might as well put that right.  Note that printjob() uses stdout if
it's for a command where the user has requested a status output; that
doesn't seem to apply here.

> I'm not sure why it doesn't just use printjob(); probably historic from
> when both of those functions were simpler.

printjob() doesn't currently do the right thing even if called at that
point.  There's no reason it couldn't, but I doubt if the result would
be a code saving or a clarification.

> } why is the 
> } second message sent to my terminal? how can i direct it to stderr?
> 
> You can't.

... the point being this is *interactive* job control based around a
terminal session.  It's not a general purpose mini-process-management
system.

Index: Src/jobs.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/jobs.c,v
retrieving revision 1.64
diff -u -r1.64 jobs.c
--- Src/jobs.c	31 Jul 2008 08:44:21 -0000	1.64
+++ Src/jobs.c	14 Mar 2009 18:36:05 -0000
@@ -1380,11 +1380,11 @@
 	} else if (prevjob == -1 || !(jobtab[prevjob].stat & STAT_STOPPED))
 	    prevjob = thisjob;
 	if (interact && jobbing && jobtab[thisjob].procs) {
-	    fprintf(stderr, "[%d]", thisjob);
+	    fprintf(shout, "[%d]", thisjob);
 	    for (pn = jobtab[thisjob].procs; pn; pn = pn->next)
-		fprintf(stderr, " %ld", (long) pn->pid);
-	    fprintf(stderr, "\n");
-	    fflush(stderr);
+		fprintf(shout, " %ld", (long) pn->pid);
+	    fprintf(shout, "\n");
+	    fflush(shout);
 	}
     }
     if (!hasprocs(thisjob))


-- 
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/



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