Date: Sun, 2 Sep 2001 16:15:14 -0400 (EDT) From: Mikhail Teterin <mi@aldan.algebra.com> To: asmodai@wxs.nl Cc: current@freebsd.org, arch@freebsd.org Subject: Re: proctitle progress reporting for dump(8) Message-ID: <200109022015.f82KFFo71687@aldan.algebra.com> In-Reply-To: <20010901194706.C33712@daemon.ninth-circle.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--0-1804289383-999461719=:969
Content-Type: TEXT/plain; charset=us-ascii
Ok, attached is the patch addding a function, which sets the proctitle
to the last output message and several calls to this function in places,
where it looked useful to me. May be, I added too many, and/or skipped
some...
Note, that I intentially did not put this functionality into the msg()
function itself -- not all messages need to be placed into the title.
But a call to my new title(void) function can be placed whereever deemed
useful. Only those, that can be followed by a long wait...
The only tricks here are to replace the \n with the \0 in the lastmsg
and to restore the title to the original before forking.
The SIGINFO handling seemed to be as simple as:
--- main.c 2001/07/09 03:06:56 1.26
+++ main.c 2001/09/02 19:58:21
@@ -274,2 +274,4 @@
+ if (signal(SIGINFO, SIG_IGN) != SIG_IGN)
+ signal(SIGHUP, sig);
if (signal(SIGHUP, SIG_IGN) != SIG_IGN)
@@ -527,2 +536,5 @@
switch(signo) {
+ case SIGINFO:
+ timeest();
+ break;
case SIGALRM:
But it just does not work :( I tried Ctrl-T and I tried killall -- no
output, besides the usual:
load: 0.11 cmd: dump 69089 [running] 0.00u 0.00s 0% 392k
Any suggestions? Thanks!
I'm only a ports committer, so if the proctitle patch is found
acceptable (wow!) -- could someone please commit it? Or tell me to
send-pr it...
-mi
--0-1804289383-999461719=:969
Content-Type: TEXT/plain; name=p-title
Content-Description: let dump update its process title with the last output message
Content-Disposition: attachment; filename=p-title
Index: dump.h
===================================================================
RCS file: /home/ncvs/src/sbin/dump/dump.h,v
retrieving revision 1.9
diff -U1 -r1.9 dump.h
--- dump.h 2001/08/10 23:12:10 1.9
+++ dump.h 2001/09/02 19:58:20
@@ -104,2 +104,3 @@
void timeest __P((void));
+void title __P((void));
time_t unctime __P((char *str));
Index: main.c
===================================================================
RCS file: /home/ncvs/src/sbin/dump/main.c,v
retrieving revision 1.26
diff -U1 -r1.26 main.c
--- main.c 2001/07/09 03:06:56 1.26
+++ main.c 2001/09/02 19:58:21
@@ -332,2 +334,3 @@
}
+ title();
sync();
@@ -358,2 +361,3 @@
msg("mapping (Pass I) [regular files]\n");
+ title();
anydirskipped = mapfiles(maxino, &tapesize);
@@ -361,2 +365,3 @@
msg("mapping (Pass II) [directories]\n");
+ title();
while (anydirskipped) {
@@ -410,2 +415,3 @@
}
+ title();
@@ -423,2 +429,3 @@
msg("dumping (Pass III) [directories]\n");
+ title();
dirty = 0; /* XXX just to get gcc to shut up */
@@ -441,2 +448,3 @@
msg("dumping (Pass IV) [regular files]\n");
+ title();
for (map = dumpinomap, ino = 1; ino < maxino; ino++) {
@@ -478,2 +486,3 @@
spcl.c_tapea / (tend_writing - tstart_writing));
+ title();
@@ -536,2 +548,3 @@
msg("Rewriting attempted as response to unknown signal.\n");
+ title();
(void)fflush(stderr);
Index: optr.c
===================================================================
RCS file: /home/ncvs/src/sbin/dump/optr.c,v
retrieving revision 1.12
diff -U1 -r1.12 optr.c
--- optr.c 2001/01/29 09:45:51 1.12
+++ optr.c 2001/09/02 19:58:21
@@ -203,2 +203,3 @@
+ setproctitle(NULL); /* restore the proctitle modified by title() */
switch (pid = fork()) {
@@ -305,2 +306,3 @@
deltat / 3600, (deltat % 3600) / 60);
+ title();
}
@@ -333,2 +335,28 @@
va_end(ap);
+}
+
+/*
+ * This function can be called to place, what msg() above pushed to
+ * stderr, into the process title, viewable with the ps-command.
+ * A side effect of this function, is it replaces the final '\n' (if any)
+ * with the '\0' in the global variable lastmsg -- to avoid the literal
+ * "\n" being put into the proctitle.
+ * So, if the lastmsg needs to be output elsewhere, that should happen
+ * before calling title().
+ */
+void title()
+{
+ int lastlen;
+
+ lastlen = strlen(lastmsg);
+ if (lastmsg[lastlen-1] == '\n')
+ lastmsg[lastlen-1] = '\0';
+
+ /*
+ * It would be unwise to run multiple dumps of same disk at
+ * same time. So ``disk'' is sufficient for identifying, to
+ * which family of dump processes this one belongs -- the
+ * other processes continue to have the original titles
+ */
+ setproctitle("%s: %s", disk, lastmsg);
}
Index: tape.c
===================================================================
RCS file: /home/ncvs/src/sbin/dump/tape.c,v
retrieving revision 1.13
diff -U1 -r1.13 tape.c
--- tape.c 2001/01/28 21:21:37 1.13
+++ tape.c 2001/09/02 19:58:22
@@ -533,2 +533,3 @@
*/
+ setproctitle(NULL); /* restore the proctitle modified by title() */
childpid = fork();
--0-1804289383-999461719=:969--
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200109022015.f82KFFo71687>
