From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52055) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aHStn-0002nJ-Ue for qemu-devel@nongnu.org; Fri, 08 Jan 2016 03:59:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aHStk-0003B7-N3 for qemu-devel@nongnu.org; Fri, 08 Jan 2016 03:59:55 -0500 Received: from mail-wm0-x231.google.com ([2a00:1450:400c:c09::231]:32980) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aHStk-0003Ax-GM for qemu-devel@nongnu.org; Fri, 08 Jan 2016 03:59:52 -0500 Received: by mail-wm0-x231.google.com with SMTP id f206so127677567wmf.0 for ; Fri, 08 Jan 2016 00:59:51 -0800 (PST) Sender: Paolo Bonzini References: <1450441266-543-1-git-send-email-berrange@redhat.com> <1450441266-543-9-git-send-email-berrange@redhat.com> From: Paolo Bonzini Message-ID: <568F7A85.4080409@redhat.com> Date: Fri, 8 Jan 2016 09:59:49 +0100 MIME-Version: 1.0 In-Reply-To: <1450441266-543-9-git-send-email-berrange@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PULL v4 8/9] io: add QIOChannelCommand class List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" , qemu-devel@nongnu.org Cc: Peter Maydell On 18/12/2015 13:21, Daniel P. Berrange wrote: > +#ifndef WIN32 > +static int qio_channel_command_abort(QIOChannelCommand *ioc, > + Error **errp) > +{ > + pid_t ret; > + int status; > + int step = 0; > + > + /* See if intermediate process has exited; if not, try a nice > + * SIGTERM followed by a more severe SIGKILL. > + */ > + rewait: > + trace_qio_channel_command_abort(ioc, ioc->pid); > + ret = waitpid(ioc->pid, &status, WNOHANG); > + trace_qio_channel_command_wait(ioc, ioc->pid, ret, status); > + if (ret == (pid_t)-1) { > + if (errno == EINTR) { > + goto rewait; > + } else { > + error_setg_errno(errp, errno, > + "Cannot wait on pid %llu", > + (unsigned long long)ioc->pid); > + return -1; > + } > + } else if (ret == 0) { > + if (step == 0) { > + kill(ioc->pid, SIGTERM); > + } else if (step == 1) { > + kill(ioc->pid, SIGKILL); Hi Daniel, Coverity complains here that step is never set to 1. Paolo > + } else { > + error_setg(errp, > + "Process %llu refused to die", > + (unsigned long long)ioc->pid); > + return -1; > + } > + usleep(10 * 1000); > + goto rewait; > + } > + > + return 0; > +} > +#endif /* ! WIN32 */ > +