mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ulrich Drepper <drepper@redhat.com>
To: "Theodore Y. Ts'o" <tytso@MIT.EDU>
Cc: George Talbot <george@brain.moberg.com>,
	Marc Lehmann <pcg@goof.com>,
	linux-kernel@vger.kernel.org
Subject: Re: Can EINTR be handled the way BSD handles it? -- a plea from a user-land  programmer...
Date: 06 Nov 2000 10:50:37 -0800	[thread overview]
Message-ID: <m33dh5aq9u.fsf@otr.mynet.cygnus.com> (raw)
In-Reply-To: <200011061655.LAA21681@tsx-prime.MIT.EDU>
In-Reply-To: "Theodore Y. Ts'o"'s message of "Mon, 6 Nov 2000 11:55:05 -0500"

"Theodore Y. Ts'o" <tytso@MIT.EDU> writes:

> Arguably though the bug is in glibc, in that if it's using signals
> behinds the scenes, it should have passed SA_RESTART to sigaction.

Why are you talking  such a nonsense?

> 
> However, from a portability point of view, you should *always* surround
> certain system calls with while loops, since even if your program
> doesn't use signals, if you run that program on a System-V derived Unix
> system, and someone types ^Z at the wrong moment, you can also get an
> EINTR.   Similarly, you should always check the return value from write
> and make sure all of what you asked to be written, was actually
> written.
> 
> What I normally do is have a full_write routine which looks something
> like this:
> 
> static errcode_t full_write(int fd, void *buf, int count)
> {
> 	char	*cp = buf;
> 	int	left = count, c;
> 
> 	while (left) {
> 		c = write(fd, cp, left);
> 		if (c < 0) {
> 			if (errno == EINTR || errno == EAGAIN)
> 				continue;
> 			return errno;
> 		}
> 		left -= c;
> 		cp += c;
> 	}
> 	return 0;
> }
> 
> It's like checking the return value from malloc().  Not everyone does
> it, but even if it's not needed 99% of the time, it's a darned good idea
> to do that.
> 
> 					- Ted
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> Please read the FAQ at http://www.tux.org/lkml/
> 
> 

-- 
---------------.                          ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Red Hat          `--' drepper at redhat.com   `------------------------
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

  reply	other threads:[~2000-11-06 18:55 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20001105042410.C3961@fuji.laendle>
2000-11-06 14:13 ` George Talbot
2000-11-06 16:55   ` Theodore Y. Ts'o
2000-11-06 18:50     ` Ulrich Drepper [this message]
2000-11-06 19:11       ` Ulrich Drepper
2000-11-06 19:37         ` kuznet
2000-11-07 15:53       ` Theodore Y. Ts'o
2000-11-07  4:46   ` dean gaudet
2000-11-04  3:06 David Feuer
  -- strict thread matches above, loose matches on Subject: below --
2000-11-03 19:29 george
2000-11-03 19:41 ` Ulrich Drepper
2000-11-03 19:49   ` george
2000-11-03 21:34     ` dean gaudet
2000-11-03 19:51   ` kuznet
2000-11-03 21:24     ` H. Peter Anvin
2000-11-03 20:20 ` Richard B. Johnson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m33dh5aq9u.fsf@otr.mynet.cygnus.com \
    --to=drepper@redhat.com \
    --cc=drepper@cygnus.com \
    --cc=george@brain.moberg.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pcg@goof.com \
    --cc=tytso@MIT.EDU \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®