[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH] tools: Improve signal handling in xen-vmtrace
On 2021-02-26, Hubert Jasudowicz wrote: > Make sure xen-vmtrace exits cleanly in case SIGPIPE is sent. This can > happen when piping the output to some other program. > > Additionaly, add volatile qualifier to interrupted flag to avoid > it being optimized away by the compiler. > > Signed-off-by: Hubert Jasudowicz <hubert.jasudowicz@xxxxxxx> > --- > tools/misc/xen-vmtrace.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/tools/misc/xen-vmtrace.c b/tools/misc/xen-vmtrace.c > index 7572e880c5..e2da043058 100644 > --- a/tools/misc/xen-vmtrace.c > +++ b/tools/misc/xen-vmtrace.c > @@ -43,7 +43,7 @@ static uint32_t domid, vcpu; > static size_t size; > static char *buf; > > -static sig_atomic_t interrupted; > +static volatile sig_atomic_t interrupted; > static void int_handler(int signum) > { > interrupted = 1; > @@ -81,6 +81,9 @@ int main(int argc, char **argv) > if ( signal(SIGINT, int_handler) == SIG_ERR ) > err(1, "Failed to register signal handler\n"); > > + if ( signal(SIGPIPE, int_handler) == SIG_ERR ) > + err(1, "Failed to register signal handler\n"); > + > if ( argc != 3 ) > { > fprintf(stderr, "Usage: %s <domid> <vcpu_id>\n", argv[0]); > -- > 2.30.0 > > Oops, forgot 4.15 tag. But IMO this should be included. Thanks Hubert Jasudowicz CERT Polska
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |