{"thread":{"id":"3305","subject":"Fix fetch-clone in the presense of signals","startedAt":"2006-02-11T18:41:22Z","lastAt":"2006-02-11T18:41:22Z","messageCount":1,"participants":["Linus Torvalds"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"15933","messageId":"Pine.LNX.4.64.0602111038400.3691@g5.osdl.org","threadId":"3305","inReplyTo":null,"subject":"Fix fetch-clone in the presense of signals","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2006-02-11T18:41:22Z","receivedAt":"2006-02-11T18:41:22Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\nWe shouldn't fail a fetch just because a signal might have interrupted\nthe read.\n\nNormally, we don't install any signal handlers, so EINTR really shouldn't \nhappen. That said, really old versions of Linux will interrupt an \ninterruptible system call even for signals that turn out to be ignored \n(SIGWINCH is the classic example - resizing your xterm would cause it). \nThe same might well be true elsewhere too.\n\nAlso, since receive_keep_pack() doesn't control the caller, it can't know \nthat no signal handlers exist.\n\nSigned-off-by: Linus Torvalds <torvalds@osdl.org>\n---\n\ndiff --git a/fetch-clone.c b/fetch-clone.c\nindex b67d976..d8216cb 100644\n--- a/fetch-clone.c\n+++ b/fetch-clone.c\n@@ -153,10 +153,13 @@ int receive_keep_pack(int fd[2], const c\n \t\tif (sz == 0)\n \t\t\tbreak;\n \t\tif (sz < 0) {\n-\t\t\terror(\"error reading pack (%s)\", strerror(errno));\n-\t\t\tclose(ofd);\n-\t\t\tunlink(tmpfile);\n-\t\t\treturn -1;\n+\t\t\tif (errno != EINTR && errno != EAGAIN) {\n+\t\t\t\terror(\"error reading pack (%s)\", strerror(errno));\n+\t\t\t\tclose(ofd);\n+\t\t\t\tunlink(tmpfile);\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\t\t\tsz = 0;\n \t\t}\n \t\tpos = 0;\n \t\twhile (pos < sz) {\n"}]}