From: Iain Patterson Date: Sun, 19 Jan 2014 18:01:36 +0000 (+0000) Subject: Fake stdin for applications which exit on EOF. X-Git-Tag: v2.22~45 X-Git-Url: http://git.iain.cx/?a=commitdiff_plain;ds=inline;h=fa2f3fe4a81e6958717ae05f6d37af2da91bcd66;hp=fa2f3fe4a81e6958717ae05f6d37af2da91bcd66;p=nssm.git Fake stdin for applications which exit on EOF. Some applications, like MonetDB server, expect to read commands on stdin. If they read a keyword, usually "exit" or "quit" or if stdin is closed, they will exit. Such applications will typically work when run in a service context via NSSM, as Windows will allocate a console window for them. However, when the service is configured to redirect stdout and/or stderr but not stdin, the application will exit immediately because it will see no input and think that the user closed stdin. To deal with this situation we interpret an AppStdin value of "|" (a single pipe character) as requesting a hack mode whereby we open a pipe and pass the reading end to the application as the stdin handle. We never actually write anything to the writing end of pipe but simply keep it around until the application exits or the service receives a stop control. Closing the pipe on receipt of a stop request may even be sufficient to close the application gracefully without resorting to any of the other stop methods. As an aside, MonetDB server can be run in batch mode, wherein it does not attempt to read from stdin at all. The hack is not necessary for it or other applications with similar functionality. Thanks Bryan Senseman. ---