mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 17:38:00 +00:00
3396c97da9
Now that the new CMake build system is encouraging us to lay out the code like a set of libraries, it seems like a good idea to make them look more _like_ libraries, by putting things into separate modules as far as possible. This fixes several previous annoyances in which you had to link against some object in order to get a function you needed, but that object also contained other functions you didn't need which included link-time symbol references you didn't want to have to deal with. The usual offender was subsidiary supporting programs including misc.c for some innocuous function and then finding they had to deal with the requirements of buildinfo(). This big reorganisation introduces three new subdirectories called 'utils', one at the top level and one in each platform subdir. In each case, the directory contains basically the same files that were previously placed in the 'utils' build-time library, except that the ones that were extremely miscellaneous (misc.c, utils.c, uxmisc.c, winmisc.c, winmiscs.c, winutils.c) have been split up into much smaller pieces.
31 lines
815 B
C
31 lines
815 B
C
/*
|
|
* PuTTY's wrapper on signal(2).
|
|
*
|
|
* Calling signal() is non-portable, as it varies in meaning between
|
|
* platforms and depending on feature macros, and has stupid semantics
|
|
* at least some of the time.
|
|
*
|
|
* This function provides the same interface as the libc function, but
|
|
* provides consistent semantics. It assumes POSIX semantics for
|
|
* sigaction() (so you might need to do some more work if you port to
|
|
* something ancient like SunOS 4).
|
|
*/
|
|
|
|
#include <signal.h>
|
|
|
|
#include "defs.h"
|
|
|
|
void (*putty_signal(int sig, void (*func)(int)))(int)
|
|
{
|
|
struct sigaction sa;
|
|
struct sigaction old;
|
|
|
|
sa.sa_handler = func;
|
|
if(sigemptyset(&sa.sa_mask) < 0)
|
|
return SIG_ERR;
|
|
sa.sa_flags = SA_RESTART;
|
|
if(sigaction(sig, &sa, &old) < 0)
|
|
return SIG_ERR;
|
|
return old.sa_handler;
|
|
}
|