X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f X-Recipient: djgpp AT delorie DOT com Message-ID: <5706E3D9.9070401@gmx.de> Date: Fri, 08 Apr 2016 00:48:57 +0200 From: "Juan Manuel Guerrero (juan DOT guerrero AT gmx DOT de) [via djgpp AT delorie DOT com]" User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.2.13) Gecko/20101206 SUSE/3.1.7 Thunderbird/3.1.7 MIME-Version: 1.0 To: djgpp AT delorie DOT com Subject: Re: Different dup2 behaviour between DOS/DJGPP and posix. References: <5706CAFA DOT 1060201 AT gmx DOT de> In-Reply-To: <5706CAFA.1060201@gmx.de> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:vqKEWkh7xXAkT7li71fBhd6isymKCqL9ucbMv3G71qaiMMYYzHH HbfTim29eRKpoi+pXcP7gw4SI6Yy+Ie4ZP8zm0RB4PtPbEM+rFXICXFJGMycswqz4NB/4vi Up6l/qXoXbzJ27zZAGUTIv+CpvrGEIsycx8U811ocmcAdT39xvISfl79f+JDYuaONSB6xkq 6Zf1jkBhKEOJPOD+BkX+A== X-UI-Out-Filterresults: notjunk:1;V01:K0:lETEMqMvs6Q=:zJx1BhJf0l8j86tzc25CYb Ev16iWPeemZJyJyTnw53lNU/M/38LdQws//E8XHq4hj8Hy0tD/vZMAk/cbN7vSK9NNLjEYBMA zplSL/KPKpuDDGUGcdJjbuv9yHx1LXcfaVCZIjrRTeggwMaZG4IZ55kEk4iy2gFmRdneE6rMk DfPawEJW+tbVJc3yHV/v59ilHO81ThqTUQ6m4sJx40GuAt+JtdxUkwk+9K2vS7DYelDQIZKKX UDKhm7a3q5RqecLLgg8MopXhk3STNyQRxgfgrCUz6dI++iNu35DRJCBkN84fjgOuD41BUEU7C 2me6wC3jzbnSYI4UFn2f/5tjOflTJSKf4Pt3gZFOkG+GIo8m7AlTmbJTTQpP0PYNM2zJsc55m QRhgi6RTeQm97K86G2bRbWtokHAQwpphsFrcDlQSnDfx4Uq2jCEHL+zDzwC9G9SMLWM82y8KX JT4PhyPIf+YDGtXSd67/vvOZYE9HFjPq676L2nlqx8ZpA+U8t0FM8qMi0yrQaaUrv594Mp3WL 0ms7SG9OIF0tVytil3GyVo+E60pM0MB1alpRREnBX/a1eFw29/5Q4nV8F+kqTnl4snukipLEe VDqP9mfsDY7P+bqxL0eH4VbRvUG14QZMUjpxOTUiSdO9sVV7g3Koa1C7EpmXvc+KzPNYTEiQk w/B/bmxJCQkwm07idjSSli3SMUqIQ5DzQa5WxZZFEozXINIg0htxqlvx/E6qZW2QPgNl4YDwf 288eO5MySdKxE2VQ8Gc0D7fGz1rIGuXY6F6xBCB8RB77sPToFFB5dgbDrEepXUtbScPSwa9SG wHUrBmw Reply-To: djgpp AT delorie DOT com Am 07.04.2016 23:02, schrieb Juan Manuel Guerrero (juan DOT guerrero AT gmx DOT de) [via djgpp AT delorie DOT com]: [snip] > The question is why DOS/DJGPP allows to close STDIN and reopen it with FD 0 > meanwhile posix seems not to allow this. Is this behaviour expected? > I have inspected the code of dup2 and the implementation seems OK. > > The consequence of this check is that Autoconf assumes that DJGPP's dup2 > implementaion does not work. OK I think I have got it. It is a bug in the DJGPP implementation of dup2. According to http://pubs.opengroup.org/onlinepubs/009695399/functions/dup.html The dup2() function shall fail if: [EBADF] The fildes argument is not a valid open file descriptor or the argument fildes2 is negative or greater than or equal to {OPEN_MAX}. The current implementation checks first if fd == newfd and if this is the case it returns inmediatly with newfd. Here some fix will be required because no one of the 3 conditions are checked. May be these error conditions were not in effect in those days when dup2 was implemented. Regards, Juan M. Guerrero