cygrunsrv.exe
can be used to install any cygwin *nix binary as a Windows service. The reason for not using a service installer such as NASSM is that cygwin binaries are dynamically linked with libraries within the Cygwin environment such that the correct tool to be used is cygrunsrv.exe
that also takes care to resolve the necessary run-time link paths for executing cygwin binaries.
Due to some Cygwin bugs, the terminals provided by Cygwin are not proper TTYs, such that programs that might rely on the terminal being a proper terminal will fail. One perfect example is a script that processes STDIN
and STDOUT
file descriptors, in particular, perhaps, via "readline", and manifests unexpected behavior such as STDIN
not being able to be read.
In order to make sure, in nodejs, that the terminal is proper, the following command can be executed:
node -p -e "Boolean(process.stdout.isTTY);
and it should print true
in case the terminal is a proper TTY terminal.
In order to run programs with an emulated TTY, the WinTTY program can be used.
In what concerns nodejs scripts, and relying on the S
parameter for env
that is supposed to work on Linux (not BSD), the header can be set to:
<ocde>
#!/usr/bin/env -S winpty node
</code>
such that the script will use winpty
first before launching node and running the script.
Another way to run programs through winpty
first is to create aliases; for example:
alias node="winpty node"