From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=38283 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OOqQb-0006Jl-VT for qemu-devel@nongnu.org; Wed, 16 Jun 2010 07:05:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OOqQa-0006NO-8h for qemu-devel@nongnu.org; Wed, 16 Jun 2010 07:05:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:65440) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OOqQa-0006N9-0B for qemu-devel@nongnu.org; Wed, 16 Jun 2010 07:05:04 -0400 Message-ID: <4C18AFCF.2000304@redhat.com> Date: Wed, 16 Jun 2010 13:04:47 +0200 From: Kevin Wolf MIME-Version: 1.0 References: <1276624421-23999-1-git-send-email-morita.kazutaka@lab.ntt.co.jp> <1276624421-23999-2-git-send-email-morita.kazutaka@lab.ntt.co.jp> In-Reply-To: <1276624421-23999-2-git-send-email-morita.kazutaka@lab.ntt.co.jp> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH 1/2] qemu-io: retry fgets() when errno is EINTR List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: MORITA Kazutaka Cc: qemu-devel@nongnu.org Am 15.06.2010 19:53, schrieb MORITA Kazutaka: > posix-aio-compat sends a signal in aio operations, so we should > consider that fgets() could be interrupted here. > > Signed-off-by: MORITA Kazutaka > --- > cmd.c | 3 +++ > 1 files changed, 3 insertions(+), 0 deletions(-) > > diff --git a/cmd.c b/cmd.c > index 2336334..460df92 100644 > --- a/cmd.c > +++ b/cmd.c > @@ -272,7 +272,10 @@ fetchline(void) > return NULL; > printf("%s", get_prompt()); > fflush(stdout); > +again: > if (!fgets(line, MAXREADLINESZ, stdin)) { > + if (errno == EINTR) > + goto again; > free(line); > return NULL; > } This looks like a loop replaced by goto (and braces are missing). What about this instead? do { ret = fgets(...) } while (ret == NULL && errno == EINTR) if (ret == NULL) { fail } Kevin