Re: [PATCH 1/2] MSVC: Do not close stdout to prevent a crash

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Op 19-11-2011 20:11, Junio C Hamano schreef:
... This happens for 'format-patch' which closes stdout after a call to
freopen which directs stdout to the format patch file.
It shouldn't do that in the first place.  This is an error on any
platform.
Correct. The clean-up codepath is for built-in command implementations
that write out their result and return 0 to signal success. If we let the
crt0 to run its usual clean-ups like closing the standard output stream,
we wouldn't be able to catch errors from there.

For built-ins that perform their own clean-ups, it is their responsibility
to be careful, hence we skip this part of the code.

We have relied on fstat(-1,&st) to correctly error out, and if MSVC build
crashes, it is a bug in its fstat() emulation, I would think.

This doesn't work because fileno(stdout) returns 1 no matter whether we closed stdout or not.

My reasoning for the proposed patch is that we call freopen(..., stdout) for each patch file to write, but we only call fclose(stdout) once. Sp, I concluded that it is not necessary to close stdout and that we just need to redirect any new output to stdout.

Vincent
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]