From: Linus Torvalds <torvalds@osdl.org>
To: Jason Riedy <ejr@EECS.Berkeley.EDU>, Junio C Hamano <junkio@cox.net>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: [PATCH 2/2] pack-objects: be incredibly anal about stdio semantics
Date: Sun, 2 Apr 2006 13:31:54 -0700 (PDT) [thread overview]
Message-ID: <Pine.LNX.4.64.0604021328380.3050@g5.osdl.org> (raw)
In-Reply-To: <Pine.LNX.4.64.0604021312510.3050@g5.osdl.org>
This is the "letter of the law" version of using fgets() properly in the
face of incredibly broken stdio implementations. We can work around the
Solaris breakage with SA_RESTART, but in case anybody else is ever that
stupid, here's the "safe" (read: "insanely anal") way to use fgets.
It probably goes without saying that I'm not terribly impressed by
Solaris libc.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
---
This is the same one that I already sent out, but re-diffed, and with a
proper commit message.
Not tested on Solaris.
Junio - I think that I forgot to Cc: you on the 1/2 patch, but you'll see
it on the git list.
diff --git a/pack-objects.c b/pack-objects.c
index 1817b58..0ea16ad 100644
--- a/pack-objects.c
+++ b/pack-objects.c
@@ -1110,8 +1110,18 @@ int main(int argc, char **argv)
setup_progress_signal();
}
- while (fgets(line, sizeof(line), stdin) != NULL) {
+ for (;;) {
unsigned char sha1[20];
+
+ if (!fgets(line, sizeof(line), stdin)) {
+ if (feof(stdin))
+ break;
+ if (!ferror(stdin))
+ die("fgets returned NULL, not EOF, not error!");
+ if (errno == EINTR)
+ continue;
+ die("fgets: %s", strerror(errno));
+ }
if (line[0] == '-') {
if (get_sha1_hex(line+1, sha1))
next prev parent reply other threads:[~2006-04-02 20:32 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-02 10:41 Solaris cloning woes partly diagnosed Junio C Hamano
2006-04-02 18:33 ` Linus Torvalds
2006-04-02 19:10 ` Jason Riedy
2006-04-02 19:22 ` Linus Torvalds
2006-04-02 19:18 ` Linus Torvalds
2006-04-02 19:52 ` Jason Riedy
2006-04-02 20:28 ` Linus Torvalds
2006-04-02 20:31 ` Linus Torvalds [this message]
2006-04-02 21:09 ` [PATCH 2/2] pack-objects: be incredibly anal about stdio semantics Junio C Hamano
2006-04-02 21:21 ` Linus Torvalds
2006-04-02 22:12 ` Jason Riedy
2006-04-02 22:58 ` Linus Torvalds
2006-04-02 22:29 ` [PATCH] Use sigaction and SA_RESTART in read-tree.c; add option in Makefile Jason Riedy
2006-04-03 1:02 ` Linus Torvalds
2006-04-03 4:20 ` Junio C Hamano
2006-04-03 4:40 ` Linus Torvalds
2006-04-03 3:06 ` Solaris cloning woes partly diagnosed Linus Torvalds
2006-04-04 18:21 ` H. Peter Anvin
2006-04-04 8:47 ` [RFH] Solaris cloning woes Junio C Hamano
2006-04-04 18:53 ` Jason Riedy
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.64.0604021328380.3050@g5.osdl.org \
--to=torvalds@osdl.org \
--cc=ejr@EECS.Berkeley.EDU \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).