Thread: Signals?

  1. #1
    cout << "Bye World!";
    Join Date
    Jun 2006
    Posts
    40

    Signals?

    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!

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    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.
    bit∙hub [bit-huhb] n. A source and destination for information.

  3. #3
    Registered User
    Join Date
    Mar 2007
    Posts
    416
    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.

  4. #4
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by bithub View Post
    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.
    signal() is an C89 standard call -- yes, really -- and Windows does support it. It probably doesn't have the SIGUSR1 signal, though.

    signal (CRT)
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  5. #5
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    Quote Originally Posted by brewbuck View Post
    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:
    Note SIGINT is not supported for any Win32 application, including Windows 98/Me and Windows NT/2000/XP.
    Writing a Windows application that uses signals is just asking for trouble.
    bit∙hub [bit-huhb] n. A source and destination for information.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A question about signals handling
    By smoking81 in forum Linux Programming
    Replies: 10
    Last Post: 10-01-2008, 03:38 PM
  2. Serial Port Monitor Control Signals Changes
    By s_Fanous in forum Linux Programming
    Replies: 5
    Last Post: 04-19-2008, 07:02 AM
  3. kill & stop signals
    By ssharish2005 in forum C Programming
    Replies: 6
    Last Post: 02-18-2008, 02:04 AM
  4. keyboard capturing
    By xlnk in forum Linux Programming
    Replies: 4
    Last Post: 01-31-2003, 01:02 PM
  5. queued signals problem, C programming related
    By Unregistered in forum Linux Programming
    Replies: 3
    Last Post: 01-22-2002, 12:30 AM