I know signals do not exist on Windows, but the word was used for lack of a better one.
I have seen a lot of similar posts, but none of them propose a solution that does not involve a third party software.
I am curious if there is a way to send some sort of "signal" to a running Windows service with vanilla Windows command line tools, which can be handled in the service's c++ source code (which is multithreaded).
I have looked at SetConsoleCtrlHandler
and GenerateConsoleCtrlEvent
, but the CTRL+Break, CTRL+C, etc. only work in interactive mode with the running program in the terminal. I am looking for something that I can open a blank slate terminal, and send a signal via a command to a running service.
C++'s standard signal library won't work due to it lacking support for multithreading.
The builtin command-line sc control
can send simple user-defined control codes to a service. The service's Handler/Ex
callback can look for those codes.
Otherwise, have the service create an IPC (interprocess communication) server to listen to, such as a socket or named pipe. You can then have a compiled console EXE, or a Powershell script, etc connect to that server and send data to it as needed.