Module Name: src Committed By: rillig Date: Tue Oct 6 16:39:23 UTC 2020
Modified Files: src/usr.bin/make: job.c Log Message: make(1): remove macro FILENO This macro was obviously wrong since it would have converted file numbers above 127 to very large numbers, close to 2^32. The fact that it didn't blow up at all is that this macro was only ever given the file descriptor 4 as an argument, which can well be represented as a char, be it signed or unsigned. And this is how the story goes: In Job_Init, two jobs are started. The server job allocates file descriptors 15 and above. The childExitJob is created next, and the pipe that it creates is [3, 4]. Using F_DUPFD, fd 3 is mapped to fd 5, and fd 3 is closed. After that, fd 4 is mapped to fd 3 (which had just been closed), and fd 4 is closed. After this initialization, file descriptors 0, 1, 2, 3 and 5 are taken. This leaves a gap at file descriptor 4, and this gap is filled whenever cmdFILE is created. Because of this particular order of events, the macro is not necessary. If it should ever become necessary on platforms like the old SunOS, the parameter minfd for JobCreatePipe should be increased to 5, which would leave the file descriptors 3 and 4 to be used by stdio streams. On 1995-11-03, when the macro was added, SunOS must have been in its very early development. In Solaris 8 (released in January 2000), FILE._file is already an unsigned char, therefore the seeming need for this macro must have been due to an older version, probably from the 2.x series of SunOS. To generate a diff of this commit: cvs rdiff -u -r1.261 -r1.262 src/usr.bin/make/job.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.