In Linux, I have created a signal handler to handle the SIGUSR1 signal.
How can I do something equivalent in Windows (this is a console app)?
Thank you!
Printable View
In Linux, I have created a signal handler to handle the SIGUSR1 signal.
How can I do something equivalent in Windows (this is a console app)?
Thank you!
Windows doesn't have signals the way Linux does. You need to either use a library that simulates Unix style signals on Windows (cygwin does this I think), or move your application to an event based implementation instead of a signal based implementation.
Like what bithub said. Windows has events, messages, and mutexes. If you're interested look up CreateEvent(), SignalEvent(), and ResetEvent() on MSDN.
edit: Sorry if those aren't the exact function names, but it'll get you there.
signal() is an C89 standard call -- yes, really -- and Windows does support it. It probably doesn't have the SIGUSR1 signal, though.
signal (CRT)
I didn't say Windows doesn't support signals. I said that they do not work the same as in Linux. For instance, SIGUSR1 does not exist. Also you get little gems like this from MSDN:
Writing a Windows application that uses signals is just asking for trouble.Quote:
Note SIGINT is not supported for any Win32 application, including Windows 98/Me and Windows NT/2000/XP.