1

I have written following CTRL+C handler but the problem is its working fine on some hosts but not working on other hosts. Can anyone please help me out.

void signalhandler( int num)
{
    signal(SIGINT, signalhandler);
}

and

EDIT:

int main()
{
  signal(SIGINT, signalhandler);
  /*------------------*/
}

[update from comment]

I mean the program does not terminate with CTRL + C while running on some hosts but the same program is getting terminated while running on some other hosts.

alk
  • 69,737
  • 10
  • 105
  • 255
Ujjwal Prakash
  • 137
  • 2
  • 11

1 Answers1

-1

When you say

"working fine on some hosts but not working on other hosts"

I assume you are referring host to other platform like Redhat, Solaris etc. From my experience, some old server use ctrl + D or ctrl + Z as interrupt signal. This is answered based on experience. Might or might not be your case.

If you need a reference to learn about signal handling in C, I suggest you to read this page first. Then you can try and read more on this page. Might be or might not be a solution on your case. But worth reading to increase knowledge about signal.

Mohd Fikrie
  • 197
  • 4
  • 21
  • 1
    Ctrl-D and Ctrl-Z are the keystrokes to feed a reading stream with an EOF. The first is used by IXish systems the latter by Windows. Using Ctrl-C to generate a SIGINT is a completely different story. – alk Jun 04 '14 at 09:34
  • I see. Thanks for explaining that. Can you share a link for that info? – Mohd Fikrie Jun 04 '14 at 09:41
  • On the usage of Ctrl-D/Ctrl-Z you might like to read here: http://stackoverflow.com/q/1118957/694576 – alk Jun 04 '14 at 09:45
  • If u have the answer will you please share it with me – Ujjwal Prakash Jun 05 '14 at 09:04