Write an error message if interrupted by a signal such as SIGINT (#187).
This commit is contained in:
@@ -1373,3 +1373,14 @@ void pv_display(pvprogramstatus_t status, readonly_pvcontrol_t control, pvtransi
|
||||
debug("%s: [%s]", "processtitle display", extra_display->display_buffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Clear the local pv__output_produced flag to indicate that the progress
|
||||
* bar display is no longer being updated and the cursor has moved past it,
|
||||
* so error messages don't need a preceding line any more.
|
||||
*/
|
||||
void pv_end_display(void)
|
||||
{
|
||||
pv__output_produced = false;
|
||||
}
|
||||
|
||||
+23
-6
@@ -30,6 +30,7 @@
|
||||
#endif
|
||||
|
||||
int pv_remote_transferstate_fetch(pvstate_t, pid_t, /*@null@ */ off_t *, bool);
|
||||
void pv_end_display(void);
|
||||
|
||||
|
||||
#if HAVE_SQRTL
|
||||
@@ -765,8 +766,8 @@ int pv_main_loop(pvstate_t state)
|
||||
pv_tty_write(&(state->flags), "\n", 1);
|
||||
}
|
||||
|
||||
if (1 == state->flags.trigger_exit)
|
||||
state->status.exit_status |= PV_ERROREXIT_SIGNAL;
|
||||
/* Tell the error routines that progress bar display has finished. */
|
||||
pv_end_display();
|
||||
|
||||
if (input_fd >= 0)
|
||||
(void) close(input_fd);
|
||||
@@ -774,6 +775,11 @@ int pv_main_loop(pvstate_t state)
|
||||
/* Calculate and display the transfer statistics. */
|
||||
pv__show_stats(state);
|
||||
|
||||
if (1 == state->flags.trigger_exit) {
|
||||
state->status.exit_status |= PV_ERROREXIT_SIGNAL;
|
||||
pv_error("%s", _("interrupted by signal"));
|
||||
}
|
||||
|
||||
return state->status.exit_status;
|
||||
}
|
||||
|
||||
@@ -1307,14 +1313,20 @@ int pv_watchfd_loop(pvstate_t state)
|
||||
}
|
||||
}
|
||||
|
||||
end_pv_watchfd_loop:
|
||||
|
||||
/* Tell the error routines that progress bar display has finished. */
|
||||
pv_end_display();
|
||||
|
||||
/*
|
||||
* If a signal caused the end of the loop, reflect that in the
|
||||
* return code.
|
||||
*/
|
||||
if (1 == state->flags.trigger_exit)
|
||||
if (1 == state->flags.trigger_exit) {
|
||||
state->status.exit_status |= PV_ERROREXIT_SIGNAL;
|
||||
pv_error("%s", _("interrupted by signal"));
|
||||
}
|
||||
|
||||
end_pv_watchfd_loop:
|
||||
/* Free all allocated sub-structures. */
|
||||
pv_freecontents_watchfd_items(watching, state->watchfd.count);
|
||||
|
||||
@@ -1448,11 +1460,16 @@ int pv_query_loop(pvstate_t state, pid_t query)
|
||||
pv_tty_write(&(state->flags), "\n", 1);
|
||||
}
|
||||
|
||||
if (1 == state->flags.trigger_exit)
|
||||
state->status.exit_status |= PV_ERROREXIT_SIGNAL;
|
||||
/* Tell the error routines that progress bar display has finished. */
|
||||
pv_end_display();
|
||||
|
||||
/* Calculate and display the transfer statistics. */
|
||||
pv__show_stats(state);
|
||||
|
||||
if (1 == state->flags.trigger_exit) {
|
||||
state->status.exit_status |= PV_ERROREXIT_SIGNAL;
|
||||
pv_error("%s", _("interrupted by signal"));
|
||||
}
|
||||
|
||||
return state->status.exit_status;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user