UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

  • Index
  • » Threads
  • » signal() function and sigaction() function

#1 2007-09-13 09:14 AM

zhn636
Member
Registered: 2007-04-24
Posts: 146

Re: signal() function and sigaction() function

I have some doubt about signal when I read APUE2:
1.whether we can use the sigaction()function instead of the signal() function when we need catch and handle the specific signal.
2.what are the differences between the signal()function and the sigaction()function?
3.and what are the advantages of use the sigaction() functions comparing to the signal() function?

Offline

#2 2007-09-13 12:18 PM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,239

Re: signal() function and sigaction() function

1. Yes. Using sigaction is preferred.

2/3. For one thing, sigaction implementations are more similar, while the behaviour of signal is implementation specific, so sigaction is more portable. For more info read their manpages.

Offline

#3 2007-11-03 07:00 AM

mlampkin
Administrator
From: Sol 3
Registered: 2002-06-12
Posts: 911
Website

Re: signal() function and sigaction() function

Just my thoughts...

This was posted under the Threads section ( pthreads since we are talking about *NIX systems )... 

Soooo...

The absolute proper way would be to use a sigmask ( ... ) call followed with sigwait or sigtimedwait in the thread handling the specific target signal... AND go ahead and do a sigaction install ( but make it part of the config / pre-compile process ) to make certain broken systems ( older linux - prethreads - etc ) don't choke...


Michael


"The only difference between me and a madman is that I'm not mad."

Salvador Dali (1904-1989)

Offline

  • Index
  • » Threads
  • » signal() function and sigaction() function

Board footer

Powered by FluxBB