microsoft / node-pty

Fork pseudoterminals in Node.JS
Other
1.42k stars 233 forks source link

patch for OpenBSD to fix undeclared identifier forkpty #637

Open ericlenio opened 8 months ago

ericlenio commented 8 months ago

Environment details

Issue description

I was getting this error while compiling:

> node-pty@1.0.0 install
> node-gyp rebuild

gyp info it worked if it ends with ok
gyp info using node-gyp@9.4.0
gyp info using node@16.14.2 | openbsd | x64
gyp info find Python using Python version 3.9.13 found at "/usr/local/bin/python3"
gyp info spawn /usr/local/bin/python3
gyp info spawn args [
gyp info spawn args   '/home/el13/incubator/node-pty/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/home/el13/incubator/node-pty/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/home/el13/incubator/node-pty/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/home/el13/.cache/node-gyp/16.14.2/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/home/el13/.cache/node-gyp/16.14.2',
gyp info spawn args   '-Dnode_gyp_dir=/home/el13/incubator/node-pty/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/home/el13/.cache/node-gyp/16.14.2/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/home/el13/incubator/node-pty',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
gypgmake: Entering directory '/home/el13/incubator/node-pty/build'
 info  CXX(target) Release/obj.target/pty/src/unix/pty.o
 spawn gmake
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
../src/unix/pty.cc:296:9: error: use of undeclared identifier 'forkpty'
  pid = forkpty(&master, nullptr, static_cast<termios*>(term), static_cast<winsize*>(&winp));
        ^
../src/unix/pty.cc:413:13: error: use of undeclared identifier 'openpty'
  int ret = openpty(&master, &slave, nullptr, NULL, static_cast<winsize*>(&winp));
            ^
2 errors generated.
gmake: *** [pty.target.mk:113: Release/obj.target/pty/src/unix/pty.o] Error 1
gmake: Leaving directory '/home/el13/incubator/node-pty/build'
gyp ERR! build error 

I was able to compile with this patch:

diff --git a/src/unix/pty.cc b/src/unix/pty.cc
index 309d38f..0889772 100644
--- a/src/unix/pty.cc
+++ b/src/unix/pty.cc
@@ -38,6 +38,8 @@
 #include <util.h>
 #elif defined(__FreeBSD__)
 #include <libutil.h>
+#elif defined(__OpenBSD__)
+#include <util.h>
 #endif

 /* Some platforms name VWERASE and VDISCARD differently */