osfhandle.h 1.0 KB

1234567891011121314151617181920212223242526
  1. // Copyright (c) 2016 GitHub, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #ifndef ATOM_NODE_OSFHANDLE_H_
  5. #define ATOM_NODE_OSFHANDLE_H_
  6. #include <windows.h>
  7. namespace node {
  8. // The _open_osfhandle and _close functions on Windows are provided by the
  9. // Visual C++ library, so the fd returned by them can only be used in the
  10. // same instance of VC++ library.
  11. // However Electron is linking with VC++ library statically, so electron.exe
  12. // shares a different instance of VC++ library with node.exe. This results
  13. // in fd created in electron.exe not usable in node.dll, so we have to ensure
  14. // we always create fd in one instance of VC++ library.
  15. // Followings wrappers are compiled in node.dll, and all code in electron.exe
  16. // should call these wrappers instead of calling _open_osfhandle directly.
  17. __declspec(dllexport) int open_osfhandle(intptr_t osfhandle, int flags);
  18. __declspec(dllexport) int close(int fd);
  19. } // namespace node
  20. #endif // ATOM_NODE_OSFHANDLE_H_