Changeset 2684 for trunk/src/kmk


Ignore:
Timestamp:
Jun 19, 2013, 1:01:48 PM (12 years ago)
Author:
bird
Message:

redirect.c: MSC fix.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/kmkbuiltin/redirect.c

    r2667 r2684  
    137137}
    138138#endif /* _MSC_VER */
     139
     140
     141#ifdef _MSC_VER
     142/** Used by safeCloseFd. */
     143static void __cdecl ignore_invalid_parameter(const wchar_t *a, const wchar_t *b, const wchar_t *c, unsigned d, uintptr_t e)
     144{
     145}
     146#endif
     147
     148
     149/**
     150 * Safely works around MS CRT's pedantic close() function.
     151 *
     152 * @param   fd      The file handle.
     153 */
     154static void safeCloseFd(int fd)
     155{
     156#ifdef _MSC_VER
     157    _invalid_parameter_handler pfnOld = _get_invalid_parameter_handler();
     158    _set_invalid_parameter_handler(ignore_invalid_parameter);
     159    close(fd);
     160    _set_invalid_parameter_handler(pfnOld);
     161#else
     162    close(fd);
     163#endif
     164}
    139165
    140166
     
    397423                }
    398424                /** @todo deal with stderr */
    399                 close(fd);
     425                safeCloseFd(fd);
    400426                continue;
    401427            }
     
    602628             * Close and open the new file descriptor.
    603629             */
    604             close(fd);
     630            safeCloseFd(fd);
    605631#if defined(_MSC_VER)
    606632            if (!strcmp(psz, "/dev/null"))
Note: See TracChangeset for help on using the changeset viewer.