{"thread":{"id":"2774","subject":"Re: [PATCH] Clean up file descriptors when calling hooks.","startedAt":"2005-12-08T03:24:28Z","lastAt":"2005-12-08T03:29:47Z","messageCount":2,"participants":["linux@horizon.com","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"13344","messageId":"20051208032428.8591.qmail@science.horizon.com","threadId":"2774","inReplyTo":null,"subject":"Re: [PATCH] Clean up file descriptors when calling hooks.","fromName":"","fromEmail":"linux@horizon.com","sentAt":"2005-12-08T03:24:28Z","receivedAt":"2005-12-08T03:24:28Z","isPatch":true,"sender":{"key":"linux@horizon.com","avatar":null},"body":"> A quick question.  I understand \"not connected to the pushing\n> connection\" is desirable, but is there a reason you chose to\n> leave them open to /dev/null, not close()d?\n\nBecause then the first open() in the hook will assign those fds,\nconfusing programs that try to use them for their traditional\npurposes.  fd 2 (stderr) is of particular concern.\n\nE.g. imagine if I ran gcc -c file.c, and it assigned file.c to fd 0,\nfile.h to fd1, and file.o to fd 2.   Then wants to print a warning\nmessage... right into the middle of the binary.  (Oversimplified\nexample, because gcc is actually several separate programs, but\nhopefully you get the idea.)\n\nIt's just safer to leave those fds open to a null device.\n"},{"id":"13345","messageId":"7vr78omfkk.fsf@assigned-by-dhcp.cox.net","threadId":"2774","inReplyTo":"20051208032428.8591.qmail@science.horizon.com","subject":"Re: [PATCH] Clean up file descriptors when calling hooks.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-12-08T03:29:47Z","receivedAt":"2005-12-08T03:29:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"linux@horizon.com writes:\n\n> E.g. imagine if I ran gcc -c file.c, and it assigned file.c to fd 0,\n> file.h to fd1, and file.o to fd 2.   Then wants to print a warning\n> message... right into the middle of the binary.  (Oversimplified\n> example, because gcc is actually several separate programs, but\n> hopefully you get the idea.)\n>\n> It's just safer to leave those fds open to a null device.\n\nOverdangerous example.  Do people realize hooks run without any\nlocking?\n"}]}