|
Lines 52-55
Link Here
|
| 52 |
#include <string.h> |
52 |
#include <string.h> |
| 53 |
#include <stdarg.h> |
53 |
#include <stdarg.h> |
|
|
54 |
#include <signal.h> |
| 54 |
#include <unistd.h> |
55 |
#include <unistd.h> |
| 55 |
#include <utmp.h> |
56 |
#include <utmp.h> |
|
Lines 191-204
Link Here
|
| 191 |
|
192 |
|
| 192 |
void |
193 |
void |
| 193 |
timeest() |
194 |
timeest(signal) |
| 194 |
{ |
195 |
{ |
| 195 |
time_t tnow; |
196 |
time_t tnow; |
| 196 |
int deltat; |
197 |
int deltat; |
| 197 |
|
198 |
|
| 198 |
(void) time((time_t *) &tnow); |
199 |
if (signal != 0) { |
|
|
200 |
/* |
| 201 |
* We might be called to handle SIGINFO. Re-schedule |
| 202 |
* the reporting to occur the next time we are called |
| 203 |
* regularly and bail out -- don't do reporting as a |
| 204 |
* signal handler -- it involves malloc-ing and other |
| 205 |
* things signal handler are not supposed to do. |
| 206 |
*/ |
| 207 |
/* |
| 208 |
* 300 seconds is a constant only used in this function |
| 209 |
*/ |
| 210 |
tschedule -= 300; |
| 211 |
return; |
| 212 |
} |
| 213 |
(void) time(&tnow); |
| 199 |
if (tnow >= tschedule) { |
214 |
if (tnow >= tschedule) { |
| 200 |
tschedule = tnow + 300; |
215 |
tschedule = tnow + 300; |
| 201 |
if (blockswritten < 500) |
|
|
| 202 |
return; |
| 203 |
deltat = tstart_writing - tnow + |
216 |
deltat = tstart_writing - tnow + |
| 204 |
(1.0 * (tnow - tstart_writing)) |
217 |
(1.0 * (tnow - tstart_writing)) |
|
Lines 207-210
Link Here
|
| 207 |
(blockswritten * 100.0) / tapesize, |
220 |
(blockswritten * 100.0) / tapesize, |
| 208 |
deltat / 3600, (deltat % 3600) / 60); |
221 |
deltat / 3600, (deltat % 3600) / 60); |
|
|
222 |
title(); |
| 209 |
} |
223 |
} |
| 210 |
} |
224 |
} |
|
Lines 235-238
Link Here
|
| 235 |
(void) vsnprintf(lastmsg, sizeof(lastmsg), fmt, ap); |
249 |
(void) vsnprintf(lastmsg, sizeof(lastmsg), fmt, ap); |
| 236 |
va_end(ap); |
250 |
va_end(ap); |
|
|
251 |
} |
| 252 |
|
| 253 |
/* |
| 254 |
* This function can be called to place, what msg() above pushed to |
| 255 |
* stderr, into the process title, viewable with the ps-command. |
| 256 |
* A side effect of this function, is it replaces the final '\n' (if any) |
| 257 |
* with the '\0' in the global variable lastmsg -- to avoid the literal |
| 258 |
* "\n" being put into the proctitle. |
| 259 |
* So, if the lastmsg needs to be output elsewhere, that should happen |
| 260 |
* before calling title(). |
| 261 |
*/ |
| 262 |
void title() |
| 263 |
{ |
| 264 |
int lastlen; |
| 265 |
|
| 266 |
lastlen = strlen(lastmsg); |
| 267 |
if (lastmsg[lastlen-1] == '\n') |
| 268 |
lastmsg[lastlen-1] = '\0'; |
| 269 |
|
| 270 |
/* |
| 271 |
* It would be unwise to run multiple dumps of same disk |
| 272 |
* at the same time. So ``disk'' is sufficient for |
| 273 |
* identifying, to which family of dump processes this |
| 274 |
* one belongs -- the other processes continue to have |
| 275 |
* the original titles. |
| 276 |
*/ |
| 277 |
setproctitle("%s: %s", disk, lastmsg); |
| 237 |
} |
278 |
} |
| 238 |
|
279 |
|