本文整理汇总了C++中sigdelset函数的典型用法代码示例。如果您正苦于以下问题:C++ sigdelset函数的具体用法?C++ sigdelset怎么用?C++ sigdelset使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sigdelset函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: StartThreads
void StartThreads( void )
{
pthread_mutex_t spinLockMutex;
pid_t childPid;
struct sigaction sa;
sigset_t sigmsk;
size_t len;
ThreadCallback_t callbacks;
GlobalAbort = FALSE;
#ifndef __CYGWIN__
len = confstr( _CS_GNU_LIBPTHREAD_VERSION, NULL, 0 );
if( len ) {
pthreadsVersion = CREATEN(char, len);
confstr( _CS_GNU_LIBPTHREAD_VERSION, pthreadsVersion, len );
}
#else
(void)len;
pthreadsVersion = memstrlink( "Cygwin" );
#endif
if( !pthreadsVersion || strstr( pthreadsVersion, "linuxthreads" ) ) {
fprintf( stderr, "havokmud requires NPTL to operate correctly.\n\n"
"The signal handling in linuxthreads is just too "
"broken to use.\n\n" );
exit( 1 );
}
/* Do we need to detach? */
if( Daemon ) {
childPid = fork();
if( childPid < 0 ) {
perror( "Couldn't detach in daemon mode" );
_exit( 1 );
}
if( childPid != 0 ) {
/* This is still the parent, report the child's pid and exit */
printf( "[Detached as PID %d]\n", childPid );
/* And exit the parent */
_exit( 0 );
}
/* After this is in the detached child */
/* Close stdin, stdout, stderr to release the tty */
close(0);
close(1);
close(2);
}
LoggingQ = QueueCreate( 1024 );
ConnectInputQ = QueueCreate( 256 );
ConnectDnsQ = QueueCreate( 64 );
InputLoginQ = QueueCreate( 256 );
InputEditorQ = QueueCreate( 256 );
InputPlayerQ = QueueCreate( 256 );
InputImmortQ = QueueCreate( 256 );
MailQ = QueueCreate( 128 );
QueryQ = QueueCreate( 1024 );
ProtobufQ = QueueCreate( 1024 );
mainThreadId = pthread_self();
/*
* Setup the sigmasks for this thread (which is the parent to all others).
* This will propogate to all children.
*/
sigfillset( &sigmsk );
sigdelset( &sigmsk, SIGUSR1 );
sigdelset( &sigmsk, SIGUSR2 );
sigdelset( &sigmsk, SIGHUP );
sigdelset( &sigmsk, SIGWINCH );
sigdelset( &sigmsk, SIGINT );
sigdelset( &sigmsk, SIGSEGV );
sigdelset( &sigmsk, SIGILL );
sigdelset( &sigmsk, SIGFPE );
pthread_sigmask( SIG_SETMASK, &sigmsk, NULL );
memset( &callbacks, 0, sizeof(ThreadCallback_t) );
callbacks.sighupFunc = mainSighup;
thread_register( &mainThreadId, "MainThread", NULL );
/* Setup signal handler for SIGUSR1 (toggles Debug) */
sa.sa_sigaction = (sigAction_t)logging_toggle_debug;
sigemptyset( &sa.sa_mask );
sa.sa_flags = SA_RESTART;
sigaction( SIGUSR1, &sa, NULL );
/* Setup the exit handler */
atexit( MainDelayExit );
/* Setup signal handler for SIGINT (shut down cleanly) */
sa.sa_sigaction = (sigAction_t)signal_interrupt;
sigemptyset( &sa.sa_mask );
sa.sa_flags = SA_RESTART;
sigaction( SIGINT, &sa, NULL );
/* Setup signal handlers that are to be propogated to all threads */
sa.sa_sigaction = (sigAction_t)signal_everyone;
//.........这里部分代码省略.........
开发者ID:tchalvak,项目名称:havokmud,代码行数:101,代码来源:master.c
示例2: exec_cmd
int exec_cmd(command_t cmd)
{
pid_t pid = fork();
if(!pid)
{
if( strcmp(cmd.inputFile,"") )
{
char string[MAX_COMMAND_LENGTH];
FILE * file = fopen(cmd.inputFile, "r");
while(fgets(string, MAX_COMMAND_LENGTH, file) != NULL)
{
char* args[MAX_PATH_LENGTH];
size_t len = strlen(string);
char last_char = string[len - 1];
if (last_char == '\n' || last_char == '\r')
{
string[len - 1] = '\0';
len = len - 1;
}
args[0] = cmd.execArgs[0];
char * temp;
temp = strtok(string," ");
args[1] = temp;
int i = 2;
while(((temp = strtok(NULL," ")) != NULL) && (i<255))
{
args[i] = temp;
i++;
}
args[i] = NULL;
int pid2 = fork();
if(!pid2)
{
if(strcmp(cmd.outputFile,""))
{
execToFile(args, cmd.outputFile);
}
else
{
checkWkdir(cmd.execArgs[0]);
if(execvp(cmd.execArgs[0],args)<0)
{
fprintf(stderr, "Error execing %s. Error# %d\n",cmd.cmdstr, errno);
exit(EXIT_FAILURE);
}
}
}
else
{
if((waitpid(pid2,&status,0))==-1)
{
fprintf(stderr, "Process encountered an error._3 ERROR%d", errno);
return EXIT_FAILURE;
}
}
}
}
else if (strcmp(cmd.outputFile,""))
{
execToFile(cmd.execArgs, cmd.outputFile);
}
else
{
// char * tmpstr[MAX_PATH_LENGTH];
// strcpy(tmpstr,cmd.execArgs[0]);
// printf("arg0: %s\n",cmd.execArgs[0]);
// printf("tmpstr: %s\n",tmpstr);
//if(execvp(tmpstr,cmd.execArgs)<0)
checkWkdir(cmd.execArgs[0]);
if(execvp(cmd.execArgs[0],cmd.execArgs)<0)
{
fprintf(stderr, "Error execing %s. Error# %d\n",cmd.cmdstr, errno);
exit(EXIT_FAILURE);
}
}
exit(0);
}
else
{
sigset_t tmpSa;
sigfillset( &tmpSa);
sigdelset(&tmpSa,SIGINT);
sigdelset(&tmpSa,SIGTSTP);
sigprocmask(SIG_SETMASK, &tmpSa, NULL);
//Start blocking signals
if(!cmd.execBg)
{
//.........这里部分代码省略.........
开发者ID:elisemmc,项目名称:EECS678_Projects,代码行数:101,代码来源:quash.c
示例3: bs_sigready
bs_sig_t bs_sigready(bs_sig_t signum) {
int out = sigismember(&ready, (int)signum);
sigdelset(&ready, signum);
return (bs_sig_t)out;
}
开发者ID:cusnir,项目名称:gocusp,代码行数:5,代码来源:signals.c
示例4: dpram_thread
static int dpram_thread(void *data)
{
int ret = 0;
int i;
struct file *filp;
struct sched_param schedpar;
dpram_task = current;
daemonize("dpram_thread");
strcpy(current->comm, "multipdp");
schedpar.sched_priority = 1;
sched_setscheduler(current, SCHED_FIFO, &schedpar);
/* set signals to accept */
siginitsetinv(¤t->blocked, sigmask(SIGUSR1));
recalc_sigpending();
for (i = 0; i < 10; i++) {
filp = dpram_open();
if (filp == NULL) {
EPRINTK("dpram_open failed! retry\n");
msleep(1000);
} else
break;
}
if (filp == NULL) {
EPRINTK("dpram_open failed!\n");
goto out;
}
dpram_filp = filp;
/* send start signal */
complete(&dpram_complete);
while (1) {
ret = dpram_poll(filp);
if (ret == -ERESTARTSYS) {
if (sigismember(¤t->pending.signal, SIGUSR1)) {
sigdelset(¤t->pending.signal, SIGUSR1);
recalc_sigpending();
ret = 0;
break;
}
}
else if (ret < 0) {
EPRINTK("dpram_poll() failed\n");
break;
}
else {
char ch;
ret = dpram_read(dpram_filp, &ch, sizeof(ch));
if(ret < 0) {
return ret;
}
if (ch == 0x7f) {
pdp_demux();
}
}
}
dpram_close(filp);
dpram_filp = NULL;
out:
dpram_task = NULL;
/* send finish signal and exit */
complete_and_exit(&dpram_complete, ret);
}
开发者ID:ARMP,项目名称:samsung_kernel_cooper,代码行数:77,代码来源:multipdp.c
示例5: main
/*****************************************************************************
* main: parse command line, start interface and spawn threads.
*****************************************************************************/
int main( int i_argc, const char *ppsz_argv[] )
{
/* The so-called POSIX-compliant MacOS X reportedly processes SIGPIPE even
* if it is blocked in all thread. Also some libraries want SIGPIPE blocked
* as they have no clue about signal masks.
* Note: this is NOT an excuse for not protecting against SIGPIPE. If
* LibVLC runs outside of VLC, we cannot rely on this code snippet. */
signal (SIGPIPE, SIG_IGN);
/* Restore default for SIGCHLD in case parent ignores it. */
signal (SIGCHLD, SIG_DFL);
#ifdef HAVE_SETENV
# ifndef NDEBUG
/* Activate malloc checking routines to detect heap corruptions. */
setenv ("MALLOC_CHECK_", "2", 1);
/* Disable the ugly Gnome crash dialog so that we properly segfault */
setenv ("GNOME_DISABLE_CRASH_DIALOG", "1", 1);
# endif
/* Clear the X.Org startup notification ID. Otherwise the UI might try to
* change the environment while the process is multi-threaded. That could
* crash. Screw you X.Org. Next time write a thread-safe specification. */
unsetenv ("DESKTOP_STARTUP_ID");
#endif
#ifndef ALLOW_RUN_AS_ROOT
if (geteuid () == 0)
{
fprintf (stderr, "VLC is not supposed to be run as root. Sorry.\n"
"If you need to use real-time priorities and/or privileged TCP ports\n"
"you can use %s-wrapper (make sure it is Set-UID root and\n"
"cannot be run by non-trusted users first).\n", ppsz_argv[0]);
return 1;
}
#endif
setlocale (LC_ALL, "");
if (isatty (STDERR_FILENO))
/* This message clutters error logs. It is print it only on a TTY.
* Forunately, LibVLC prints version infos with -vv anyhow. */
fprintf (stderr, "VLC media player %s (revision %s)\n",
libvlc_get_version(), libvlc_get_changeset());
/* Synchronously intercepted POSIX signals.
*
* In a threaded program such as VLC, the only sane way to handle signals
* is to block them in all threads but one - this is the only way to
* predict which thread will receive them. If any piece of code depends
* on delivery of one of this signal it is intrinsically not thread-safe
* and MUST NOT be used in VLC, whether we like it or not.
* There is only one exception: if the signal is raised with
* pthread_kill() - we do not use this in LibVLC but some pthread
* implementations use them internally. You should really use conditions
* for thread synchronization anyway.
*
* Signal that request a clean shutdown, and force an unclean shutdown
* if they are triggered again 2+ seconds later.
* We have to handle SIGTERM cleanly because of daemon mode.
* Note that we set the signals after the vlc_create call. */
static const int sigs[] = {
SIGINT, SIGHUP, SIGQUIT, SIGTERM,
/* Signals that cause a no-op:
* - SIGPIPE might happen with sockets and would crash VLC. It MUST be
* blocked by any LibVLC-dependent application, not just VLC.
* - SIGCHLD comes after exec*() (such as httpd CGI support) and must
* be dequeued to cleanup zombie processes.
*/
SIGPIPE, SIGCHLD
};
sigset_t set;
sigemptyset (&set);
for (unsigned i = 0; i < sizeof (sigs) / sizeof (sigs[0]); i++)
sigaddset (&set, sigs[i]);
#ifdef HAVE_MAEMO
sigaddset (&set, SIGRTMIN);
{
struct sigaction act = { .sa_handler = dummy_handler, };
sigaction (SIGRTMIN, &act, NULL);
}
#endif
/* Block all these signals */
pthread_sigmask (SIG_BLOCK, &set, NULL);
sigdelset (&set, SIGPIPE);
sigdelset (&set, SIGCHLD);
/* Note that FromLocale() can be used before libvlc is initialized */
const char *argv[i_argc + 3];
int argc = 0;
argv[argc++] = "--no-ignore-config";
#ifdef TOP_BUILDDIR
argv[argc++] = FromLocale ("--plugin-path="TOP_BUILDDIR"/modules");
#endif
//.........这里部分代码省略.........
开发者ID:paa,项目名称:vlc,代码行数:101,代码来源:vlc.c
示例6: main
int main (int argc, char *argv[])
{
pthread_mutexattr_t mattr;
pthread_condattr_t cattr;
pthread_attr_t pattr;
int i, policy, main_prio;
void * exit_status;
sigset_t mask;
struct sigaction act;
struct sched_param param;
logfile = stdout;
assert (pthread_getschedparam (pthread_self (), &policy, ¶m) == 0);
main_prio = param.sched_priority;
/* Setupt our signal mask. */
sigfillset (&mask);
sigdelset (&mask, SIGINT);
sigprocmask (SIG_SETMASK, &mask, NULL);
/* Install a signal handler for SIGINT */
sigemptyset (&act.sa_mask);
sigaddset (&act.sa_mask, SIGINT);
act.sa_handler = sighandler;
act.sa_flags = SA_RESTART;
sigaction (SIGINT, &act, NULL);
/* This test relies on the concurrency level being 1. */
pthread_setconcurrency(1);
/*
* Initialize the thread attribute.
*/
assert (pthread_attr_init (&pattr) == 0);
assert (pthread_attr_setdetachstate (&pattr,
PTHREAD_CREATE_JOINABLE) == 0);
/*
* Initialize and create the waiter and condvar mutexes.
*/
assert (pthread_mutexattr_init (&mattr) == 0);
assert (pthread_mutex_init (&waiter_mutex, &mattr) == 0);
assert (pthread_mutex_init (&cond_mutex, &mattr) == 0);
/*
* Initialize and create a condition variable.
*/
assert (pthread_condattr_init (&cattr) == 0);
assert (pthread_cond_init (&cond_var, &cattr) == 0);
/* Create a pipe to catch the results of thread wakeups. */
assert (pipe (pipefd) == 0);
#if defined(_LIBC_R_) && defined(DEBUG)
assert (pthread_switch_add_np (kern_switch) == 0);
#endif
/*
* Create the waiting threads.
*/
for (i = 0; i < NUM_THREADS; i++) {
assert (pthread_cond_init (&states[i].cond_var, &cattr) == 0);
states[i].id = (u_int8_t) i; /* NUM_THREADS must be <= 256 */
states[i].status = 0;
states[i].cmd.cmd_id = CMD_NONE;
states[i].flags = 0; /* No flags yet. */
assert (pthread_create (&states[i].tid, &pattr, waiter,
(void *) &states[i]) == 0);
param.sched_priority = main_prio - 10 + i;
states[i].priority = param.sched_priority;
assert (pthread_setschedparam (states[i].tid, SCHED_OTHER,
¶m) == 0);
#if defined(_LIBC_R_)
{
char buf[30];
snprintf (buf, sizeof(buf), "waiter_%d", i);
pthread_set_name_np (states[i].tid, buf);
}
#endif
}
/* Allow the threads to start. */
sleep (1);
log_trace ("Done creating threads.\n");
log ("\n");
mutex_init_test ();
log ("\n");
mutex_destroy_test ();
log ("\n");
mutex_lock_test ();
log ("\n");
mutex_unlock_test ();
log ("\n");
queueing_order_test ();
log ("\n");
mutex_prioinherit_test ();
log ("\n");
//.........这里部分代码省略.........
开发者ID:AhmadTux,项目名称:freebsd,代码行数:101,代码来源:mutex_d.c
示例7: OPENSSL_cpuid_setup
void OPENSSL_cpuid_setup(void)
{
char *e;
struct sigaction ill_oact,ill_act;
sigset_t oset;
static int trigger=0;
if (trigger) return;
trigger=1;
sigfillset(&all_masked);
sigdelset(&all_masked,SIGILL);
sigdelset(&all_masked,SIGTRAP);
#ifdef SIGEMT
sigdelset(&all_masked,SIGEMT);
#endif
sigdelset(&all_masked,SIGFPE);
sigdelset(&all_masked,SIGBUS);
sigdelset(&all_masked,SIGSEGV);
if ((e=getenv("OPENSSL_ppccap")))
{
OPENSSL_ppccap_P=strtoul(e,NULL,0);
return;
}
OPENSSL_ppccap_P = 0;
#if defined(_AIX)
if (sizeof(size_t)==4)
{
struct utsname uts;
# if defined(_SC_AIX_KERNEL_BITMODE)
if (sysconf(_SC_AIX_KERNEL_BITMODE)!=64) return;
# endif
if (uname(&uts)!=0 || atoi(uts.version)<6) return;
}
#endif
memset(&ill_act,0,sizeof(ill_act));
ill_act.sa_handler = ill_handler;
ill_act.sa_mask = all_masked;
sigprocmask(SIG_SETMASK,&ill_act.sa_mask,&oset);
sigaction(SIGILL,&ill_act,&ill_oact);
if (sizeof(size_t)==4)
{
#ifdef __linux
struct utsname uts;
if (uname(&uts)==0 && strcmp(uts.machine,"ppc64")==0)
#endif
if (sigsetjmp(ill_jmp,1) == 0)
{
OPENSSL_ppc64_probe();
OPENSSL_ppccap_P |= PPC_FPU64;
}
}
else
{
/*
* Wanted code detecting POWER6 CPU and setting PPC_FPU64
*/
}
if (sigsetjmp(ill_jmp,1) == 0)
{
OPENSSL_altivec_probe();
OPENSSL_ppccap_P |= PPC_ALTIVEC;
}
sigaction (SIGILL,&ill_oact,NULL);
sigprocmask(SIG_SETMASK,&oset,NULL);
}
开发者ID:0culus,项目名称:openssl,代码行数:74,代码来源:ppccap.c
示例8: g_thread_init
int AP_UnixApp::main(const char * szAppName, int argc, char ** argv)
{
// This is a static function.
if (!g_thread_supported ())
g_thread_init (NULL);
// initialize our application.
int exit_status = 0;
AP_UnixApp * pMyUnixApp = new AP_UnixApp(szAppName);
#ifdef WITH_CHAMPLAIN
gtk_clutter_init (&argc, &argv);
#endif
/* this brace is here to ensure that our local variables on the stack
* do not outlive the application object by giving them a lower scope
*/
{
XAP_Args XArgs = XAP_Args(argc, argv);
AP_Args Args = AP_Args(&XArgs, szAppName, pMyUnixApp);
#ifdef LOGFILE
UT_String sLogFile = pMyUnixApp->getUserPrivateDirectory();
sLogFile += "abiLogFile";
logfile = fopen(sLogFile.c_str(),"a+");
fprintf(logfile,"About to do gtk_set_locale \n");
fprintf(logfile,"New logfile \n");
#endif
// Step 1: Initialize GTK and create the APP.
// hack needed to intialize gtk before ::initialize
setlocale(LC_ALL, "");
gboolean have_display = gtk_init_check(&argc, &argv);
#ifdef LOGFILE
fprintf(logfile,"Got display %d \n",have_display);
fprintf(logfile,"Really display %d \n",have_display);
#endif
if (have_display > 0) {
Args.addOptions(gtk_get_option_group(TRUE));
Args.parseOptions();
}
else {
// no display, but we still need to at least parse our own arguments, damnit, for --to, --to-png, and --print
Args.addOptions(gtk_get_option_group(FALSE));
Args.parseOptions();
}
// if the initialize fails, we don't have icons, fonts, etc.
if (!pMyUnixApp->initialize(have_display))
{
delete pMyUnixApp;
return -1; // make this something standard?
}
// Setup signal handlers, primarily for segfault
// If we segfaulted before here, we *really* blew it
struct sigaction sa;
sa.sa_handler = signalWrapper;
sigfillset(&sa.sa_mask); // We don't want to hear about other signals
sigdelset(&sa.sa_mask, SIGABRT); // But we will call abort(), so we can't ignore that
#if defined (SA_NODEFER) && defined (SA_RESETHAND)
sa.sa_flags = SA_NODEFER | SA_RESETHAND; // Don't handle nested signals
#else
sa.sa_flags = 0;
#endif
sigaction(SIGSEGV, &sa, NULL);
sigaction(SIGBUS, &sa, NULL);
sigaction(SIGILL, &sa, NULL);
sigaction(SIGQUIT, &sa, NULL);
sigaction(SIGFPE, &sa, NULL);
// TODO: handle SIGABRT
// Step 2: Handle all non-window args.
bool windowlessArgsWereSuccessful = true;
if (!Args.doWindowlessArgs(windowlessArgsWereSuccessful )) {
delete pMyUnixApp;
return (windowlessArgsWereSuccessful ? 0 : -1);
}
if (have_display) {
// Step 3: Create windows as appropriate.
// if some args are botched, it returns false and we should
// continue out the door.
// We used to check for bShowApp here. It shouldn't be needed
// anymore, because doWindowlessArgs was supposed to bail already. -PL
if (pMyUnixApp->openCmdLineFiles(&Args))
{
#if defined(EMBEDDED_TARGET) && EMBEDDED_TARGET == EMBEDDED_TARGET_HILDON
s_bInitDone = true;
pMyUnixApp->processStartupQueue();
#endif
// turn over control to gtk
gtk_main();
}
else
//.........这里部分代码省略.........
开发者ID:lokeshguddu,项目名称:AbiWord,代码行数:101,代码来源:ap_UnixApp.cpp
示例9: do_trace
//.........这里部分代码省略.........
/* Defer the exit if the traced process has an VFS call pending. */
if (child->mp_flags & VFS_CALL)
child->mp_exitstatus = (int) m_in.data; /* save for later */
else
exit_proc(child, (int) m_in.data, FALSE /*dump_core*/);
/* Do not reply to the caller until VFS has processed the exit
* request.
*/
return(SUSPEND);
case T_SETOPT: /* set trace options */
child->mp_trace_flags = m_in.data;
mp->mp_reply.reply_trace = 0;
return(OK);
case T_GETRANGE:
case T_SETRANGE: /* get/set range of values */
r = sys_datacopy(who_e, (vir_bytes) m_in.PMTRACE_ADDR,
SELF, (vir_bytes) &pr, (phys_bytes) sizeof(pr));
if (r != OK) return(r);
if (pr.pr_space != TS_INS && pr.pr_space != TS_DATA) return(EINVAL);
if (pr.pr_size == 0 || pr.pr_size > LONG_MAX) return(EINVAL);
seg = (pr.pr_space == TS_INS) ? T : D;
if (req == T_GETRANGE)
r = sys_vircopy(child->mp_endpoint, seg, (vir_bytes) pr.pr_addr,
who_e, D, (vir_bytes) pr.pr_ptr,
(phys_bytes) pr.pr_size);
else
r = sys_vircopy(who_e, D, (vir_bytes) pr.pr_ptr,
child->mp_endpoint, seg, (vir_bytes) pr.pr_addr,
(phys_bytes) pr.pr_size);
if (r != OK) return(r);
mp->mp_reply.reply_trace = 0;
return(OK);
case T_DETACH: /* detach from traced process */
if (m_in.data < 0 || m_in.data >= _NSIG) return(EINVAL);
child->mp_tracer = NO_TRACER;
/* Let all tracer-pending signals through the filter. */
for (i = 1; i < _NSIG; i++) {
if (sigismember(&child->mp_sigtrace, i)) {
(void) sigdelset(&child->mp_sigtrace, i);
check_sig(child->mp_pid, i, FALSE /* ksig */);
}
}
if (m_in.data > 0) { /* issue signal */
sig_proc(child, (int) m_in.data, TRUE /*trace*/,
FALSE /* ksig */);
}
/* Resume the child as if nothing ever happened. */
child->mp_flags &= ~STOPPED;
child->mp_trace_flags = 0;
check_pending(child);
break;
case T_RESUME:
case T_STEP:
case T_SYSCALL: /* resume execution */
if (m_in.data < 0 || m_in.data >= _NSIG) return(EINVAL);
if (m_in.data > 0) { /* issue signal */
sig_proc(child, (int) m_in.data, FALSE /*trace*/,
FALSE /* ksig */);
}
/* If there are any other signals waiting to be delivered,
* feign a successful resumption.
*/
for (i = 1; i < _NSIG; i++) {
if (sigismember(&child->mp_sigtrace, i)) {
mp->mp_reply.reply_trace = 0;
return(OK);
}
}
child->mp_flags &= ~STOPPED;
check_pending(child);
break;
}
r = sys_trace(req, child->mp_endpoint, m_in.PMTRACE_ADDR, &m_in.data);
if (r != OK) return(r);
mp->mp_reply.reply_trace = m_in.data;
return(OK);
}
开发者ID:Spenser309,项目名称:CS551,代码行数:101,代码来源:trace.c
示例10: remove_sync_sigs
static void remove_sync_sigs(sigset_t *sig_mask)
{
#ifdef SIGABRT
sigdelset(sig_mask, SIGABRT);
#endif
#ifdef SIGBUS
sigdelset(sig_mask, SIGBUS);
#endif
#ifdef SIGEMT
sigdelset(sig_mask, SIGEMT);
#endif
#ifdef SIGFPE
sigdelset(sig_mask, SIGFPE);
#endif
#ifdef SIGILL
sigdelset(sig_mask, SIGILL);
#endif
#ifdef SIGIOT
sigdelset(sig_mask, SIGIOT);
#endif
#ifdef SIGPIPE
sigdelset(sig_mask, SIGPIPE);
#endif
#ifdef SIGSEGV
sigdelset(sig_mask, SIGSEGV);
#endif
#ifdef SIGSYS
sigdelset(sig_mask, SIGSYS);
#endif
#ifdef SIGTRAP
sigdelset(sig_mask, SIGTRAP);
#endif
/* the rest of the signals removed from the mask in this function
* absolutely must be removed; you cannot block synchronous signals
* (requirement of pthreads API)
*
* SIGUSR2 is being removed from the mask for the convenience of
* Purify users (Solaris, HP-UX, SGI) since Purify uses SIGUSR2
*/
#ifdef SIGUSR2
sigdelset(sig_mask, SIGUSR2);
#endif
}
开发者ID:AAthresh,项目名称:quantlib,代码行数:44,代码来源:signals.c
示例11: APR_DECLARE
APR_DECLARE(apr_status_t) apr_signal_thread(int(*signal_handler)(int signum))
{
sigset_t sig_mask;
#if APR_HAVE_SIGWAIT
int (*sig_func)(int signum) = (int (*)(int))signal_handler;
#endif
/* This thread will be the one responsible for handling signals */
sigfillset(&sig_mask);
/* On certain platforms, sigwait() returns EINVAL if any of various
* unblockable signals are included in the mask. This was first
* observed on AIX and Tru64.
*/
#ifdef SIGKILL
sigdelset(&sig_mask, SIGKILL);
#endif
#ifdef SIGSTOP
sigdelset(&sig_mask, SIGSTOP);
#endif
#ifdef SIGCONT
sigdelset(&sig_mask, SIGCONT);
#endif
#ifdef SIGWAITING
sigdelset(&sig_mask, SIGWAITING);
#endif
/* no synchronous signals should be in the mask passed to sigwait() */
remove_sync_sigs(&sig_mask);
/* On AIX (4.3.3, at least), sigwait() won't wake up if the high-
* order bit of the second word of flags is turned on. sigdelset()
* returns an error when trying to turn this off, so we'll turn it
* off manually.
*
* Note that the private fields differ between 32-bit and 64-bit
* and even between _ALL_SOURCE and !_ALL_SOURCE. Except that on
* AIX 4.3 32-bit builds and 64-bit builds use the same definition.
*
* Applicable AIX fixes such that this is no longer needed:
*
* APAR IY23096 for AIX 51B, fix included in AIX 51C, and
* APAR IY24162 for 43X.
*/
#if defined(_AIX)
#if defined(__64BIT__) && defined(_AIXVERSION_510)
#ifdef _ALL_SOURCE
sig_mask.ss_set[3] &= 0x7FFFFFFF;
#else /* not _ALL_SOURCE */
sig_mask.__ss_set[3] &= 0x7FFFFFFF;
#endif
#else /* not 64-bit build, or 64-bit build on 4.3 */
#ifdef _ALL_SOURCE
sig_mask.hisigs &= 0x7FFFFFFF;
#else /* not _ALL_SOURCE */
sig_mask.__hisigs &= 0x7FFFFFFF;
#endif
#endif
#endif /* _AIX */
while (1) {
#if APR_HAVE_SIGWAIT
int signal_received;
if (apr_sigwait(&sig_mask, &signal_received) != 0)
{
/* handle sigwait() error here */
}
if (sig_func(signal_received) == 1) {
return APR_SUCCESS;
}
#elif HAVE_SIGSUSPEND
sigsuspend(&sig_mask);
#else
#error No apr_sigwait() and no sigsuspend()
#endif
}
}
开发者ID:AAthresh,项目名称:quantlib,代码行数:79,代码来源:signals.c
示例12: main
int
main(int argc, char **argv) {
int status;
pid_t waited;
char *device, *real_device, *physicalDevice = NULL;
char *boot = NULL;
shvarFile *ifcfg;
sigset_t blockedsigs, unblockedsigs;
int pppdPid = 0;
int timeout = 30;
char *temp;
gboolean dying = FALSE;
int sendsig;
gboolean connectedOnce = FALSE;
int maxfail = 0; // MAXFAIL Patch <[email protected]>
if (argc < 2) {
fprintf (stderr, "usage: ppp-watch <interface-name> [boot]\n");
exit(30);
}
if (strncmp(argv[1], "ifcfg-", 6) == 0) {
device = argv[1] + 6;
} else {
device = argv[1];
}
detach(device); /* Prepare a child process to monitor pppd. When we
return, we'll be in the child. */
if ((argc > 2) && (strcmp("boot", argv[2]) == 0)) {
boot = argv[2];
}
ifcfg = shvarfilesGet(device);
if (ifcfg == NULL)
failureExit(28);
real_device = svGetValue(ifcfg, "DEVICE");
if (real_device == NULL)
real_device = device;
doPidFile(real_device);
/* We'll want to know which signal interrupted our sleep below, so
* attach a signal handler to these. */
set_signal(SIGTERM, signal_tracker);
set_signal(SIGINT, signal_tracker);
set_signal(SIGHUP, signal_tracker);
set_signal(SIGIO, signal_tracker);
set_signal(SIGCHLD, signal_tracker);
/* We time out only if we're being run at boot-time. */
if (boot) {
temp = svGetValue(ifcfg, "BOOTTIMEOUT");
if (temp) {
timeout = atoi(temp);
if (timeout < 1) timeout = 1;
free(temp);
} else {
timeout = 30;
}
set_signal(SIGALRM, signal_tracker);
alarm(timeout);
}
/* Register us to get a signal when something changes. Yes, that's vague. */
fork_exec(TRUE, "/sbin/netreport", NULL, NULL, NULL);
/* Reset theSigchld, which should have been triggered by netreport. */
theSigchld = 0;
/* We don't set up the procmask until after we have received the netreport
* signal. Do so now. */
sigemptyset(&blockedsigs);
sigaddset(&blockedsigs, SIGTERM);
sigaddset(&blockedsigs, SIGINT);
sigaddset(&blockedsigs, SIGHUP);
sigaddset(&blockedsigs, SIGIO);
sigaddset(&blockedsigs, SIGCHLD);
if (boot) {
sigaddset(&blockedsigs, SIGALRM);
}
sigprocmask(SIG_BLOCK, &blockedsigs, NULL);
sigfillset(&unblockedsigs);
sigdelset(&unblockedsigs, SIGTERM);
sigdelset(&unblockedsigs, SIGINT);
sigdelset(&unblockedsigs, SIGHUP);
sigdelset(&unblockedsigs, SIGIO);
sigdelset(&unblockedsigs, SIGCHLD);
if (boot) {
sigdelset(&unblockedsigs, SIGALRM);
}
sigprocmask(SIG_UNBLOCK, &unblockedsigs, NULL);
/* Initialize the retry timeout using the RETRYTIMEOUT setting. */
temp = svGetValue(ifcfg, "RETRYTIMEOUT");
if (temp) {
timeout = atoi(temp);
//.........这里部分代码省略.........
开发者ID:OpenMandrivaSoftware,项目名称:initscripts,代码行数:101,代码来源:ppp-watch.c
示例13: pqinitmask
/*
* Initialize BlockSig, UnBlockSig, and StartupBlockSig.
*
* BlockSig is the set of signals to block when we are trying to block
* signals. This includes all signals we normally expect to get, but NOT
* signals that should never be turned off.
*
* StartupBlockSig is the set of signals to block during startup packet
* collection; it's essentially BlockSig minus SIGTERM, SIGQUIT, SIGALRM.
*
* UnBlockSig is the set of signals to block when we don't want to block
* signals (is this ever nonzero??)
*/
void
pqinitmask(void)
{
sigemptyset(&UnBlockSig);
/* First set all signals, then clear some. */
sigfillset(&BlockSig);
sigfillset(&StartupBlockSig);
/*
* Unmark those signals that should never be blocked. Some of these signal
* names don't exist on all platforms. Most do, but might as well ifdef
* them all for consistency...
*/
#ifdef SIGTRAP
sigdelset(&BlockSig, SIGTRAP);
sigdelset(&StartupBlockSig, SIGTRAP);
#endif
#ifdef SIGABRT
sigdelset(&BlockSig, SIGABRT);
sigdelset(&StartupBlockSig, SIGABRT);
#endif
#ifdef SIGILL
sigdelset(&BlockSig, SIGILL);
sigdelset(&StartupBlockSig, SIGILL);
#endif
#ifdef SIGFPE
sigdelset(&BlockSig, SIGFPE);
sigdelset(&StartupBlockSig, SIGFPE);
#endif
#ifdef SIGSEGV
sigdelset(&BlockSig, SIGSEGV);
sigdelset(&StartupBlockSig, SIGSEGV);
#endif
#ifdef SIGBUS
sigdelset(&BlockSig, SIGBUS);
sigdelset(&StartupBlockSig, SIGBUS);
#endif
#ifdef SIGSYS
sigdelset(&BlockSig, SIGSYS);
sigdelset(&StartupBlockSig, SIGSYS);
#endif
#ifdef SIGCONT
sigdelset(&BlockSig, SIGCONT);
sigdelset(&StartupBlockSig, SIGCONT);
#endif
/* Signals unique to startup */
#ifdef SIGQUIT
sigdelset(&StartupBlockSig, SIGQUIT);
#endif
#ifdef SIGTERM
sigdelset(&StartupBlockSig, SIGTERM);
#endif
#ifdef SIGALRM
sigdelset(&StartupBlockSig, SIGALRM);
#endif
}
开发者ID:0x0FFF,项目名称:postgres,代码行数:71,代码来源:pqsignal.c
示例14: setup_signals
static void setup_signals(void)
{
struct sigaction sa = { .sa_handler = signal_handler, .sa_flags = 0 };
sigset_t ss;
do
{
if (sigfillset(&ss) == -1) break;
if (sigemptyset(&sa.sa_mask) == -1) break;
if (sigaction(SIGCHLD, &sa, NULL) == -1 || sigdelset(&ss, SIGCHLD) == -1) break;
if (sigaction(SIGUSR1, &sa, NULL) == -1 || sigdelset(&ss, SIGUSR1) == -1) break;
if (sigaction(SIGUSR2, &sa, NULL) == -1 || sigdelset(&ss, SIGUSR2) == -1) break;
if (sigprocmask(SIG_SETMASK, &ss, NULL) == -1) break;
return;
}
while (false);
fatal("Error while setting up signal handlers.\n");
}
static void child_setup_signals(void)
{
do
{
struct sigaction sa = { .sa_handler = SIG_DFL, .sa_flags = 0 };
if (sigemptyset(&sa.sa_mask) == -1) break;
if (sigaction(SIGCHLD, &sa, NULL) == -1) break;
if (sigaction(SIGUSR1, &sa, NULL) == -1) break;
if (sigaction(SIGUSR2, &sa, NULL) == -1) break;
if (sigprocmask(SIG_SETMASK, &sa.sa_mask, NULL) == -1) break;
return;
}
while (false);
fatal("<child> Error while setting up signal handlers.\n");
}
static void invoke_command(char *command, char **argv, pid_t *child_pid, int *ptm)
{
char* slavename = open_ptm(ptm);
if (slavename == NULL)
fatal("Error while opening pseudo-terminal.\n");
struct winsize wsize;
if (ioctl(STDIN_FILENO, TIOCGWINSZ, &wsize) == -1)
fatal("Error while getting the terminal size.\n");
struct termios attr;
if (tcgetattr(*ptm, &attr) == -1)
fatal("Error while getting the pseudo-terminal attributes.\n");
switch (*child_pid = fork())
{
case -1:
fatal("Fork failed.\n");
case 0:
/* child: */
drop_privileges();
if (close(*ptm) == -1)
fatal("<child> Error while closing the master pseudo-terminal\n");
if (setsid() == -1)
fatal("<child> Error while creating a session\n");
assert(slavename != NULL);
int pts = open(slavename, O_RDWR);
if (pts == -1)
fatal("<child> Error while opening the slave pseudo-terminal\n");
init_pty(pts, &wsize, attr);
child_setup_signals();
execvp(command, argv);
fatal("<child> Execution failed.\n");
default:
/* parent: */
return;
}
}
static void clear(void)
{
writes(STDOUT_FILENO, "\033[0m\033[H\033[J");
}
开发者ID:jwilk,项目名称:ulock,代码行数:78,代码来源:ulock.c
示例15: main
int main ( int argc, char **argv )
{
pthread_mutex_t spinLockMutex;
pid_t childPid;
struct sigaction sa;
sigset_t sigmsk;
size_t len;
ThreadCallback_t callbacks;
GlobalAbort = false;
/* Parse the command line options */
MainParseArgs( argc, argv );
#ifndef __CYGWIN__
len = confstr( _CS_GNU_LIBPTHREAD_VERSION, NULL, 0 );
if( len ) {
pthreadsVersion = (char *)malloc(len);
confstr( _CS_GNU_LIBPTHREAD_VERSION, pthreadsVersion, len );
}
if( !pthreadsVersion || strstr( pthreadsVersion, "linuxthreads" ) ) {
fprintf( stderr, "beirdobot requires NPTL to operate correctly.\n\n"
"The signal handling in linuxthreads is just too "
"broken to use.\n\n" );
exit( 1 );
}
#else
len = 0;
#endif
/* Do we need to detach? */
if( Daemon ) {
childPid = fork();
if( childPid < 0 ) {
perror( "Couldn't detach in daemon mode" );
_exit( 1 );
}
if( childPid != 0 ) {
/* This is still the parent, report the child's pid and exit */
printf( "[Detached as PID %d]\n", childPid );
/* And exit the parent */
_exit( 0 );
}
/* After this is in the detached child */
/* Close stdin, stdout, stderr to release the tty */
close(0);
close(1);
close(2);
}
mainThreadId = pthread_self();
/*
* Setup the sigmasks for this thread (which is the parent to all others).
* This will propogate to all children.
*/
sigfillset( &sigmsk );
sigdelset( &sigmsk, SIGUSR1 );
sigdelset( &sigmsk, SIGUSR2 );
sigdelset( &sigmsk, SIGHUP );
sigdelset( &sigmsk, SIGWINCH );
sigdelset( &sigmsk, SIGINT );
sigdelset( &sigmsk, SIGSEGV );
sigdelset( &sigmsk, SIGILL );
sigdelset( &sigmsk, SIGFPE );
pthread_sigmask( SIG_SETMASK, &sigmsk, NULL );
/* Initialize the non-threadsafe CURL library functionality */
curl_global_init( CURL_GLOBAL_ALL );
/* Start up the Logging thread */
logging_initialize(TRUE);
memset( &callbacks, 0, sizeof(ThreadCallback_t) );
callbacks.sighupFunc = mainSighup;
thread_register( &mainThreadId, "thread_main", &callbacks );
/* Setup signal handler for SIGUSR1 (toggles Debug) */
sa.sa_sigaction = (sigAction_t)logging_toggle_debug;
sigemptyset( &sa.sa_mask );
sa.sa_flags = SA_RESTART;
sigaction( SIGUSR1, &sa, NULL );
/* Setup the exit handler */
atexit( MainDelayExit );
/* Setup signal handler for SIGINT (shut down cleanly) */
sa.sa_sigaction = signal_interrupt;
sigemptyset( &sa.sa_mask );
sa.sa_flags = SA_RESTART;
sigaction( SIGINT, &sa, NULL );
/* Setup signal handlers that are to be propogated to all threads */
sa.sa_sigaction = signal_everyone;
sigemptyset( &sa.sa_mask );
sa.sa_flags = SA_RESTART | SA_SIGINFO;
//.........这里部分代码省略.........
开发者ID:Beirdo,项目名称:beirdobot,代码行数:101,代码来源:main.c
示例16: WalWriterMain
/*
* Main entry point for walwriter process
*
* This is invoked from BootstrapMain, which has already created the basic
* execution environment, but not enabled signals yet.
*/
void
WalWriterMain(void)
{
sigjmp_buf local_sigjmp_buf;
MemoryContext walwriter_context;
/*
* If possible, make this process a group leader, so that the postmaster
* can signal any child processes too. (walwriter probably never has any
* child processes, but for consistency we make all postmaster child
* processes do this.)
*/
#ifdef HAVE_SETSID
if (setsid() < 0)
elog(FATAL, "setsid() failed: %m");
#endif
/*
* Properly accept or ignore signals the postmaster might send us
*
* We have no particular use for SIGINT at the moment, but seems
* reasonable to treat like SIGTERM.
*/
pqsignal(SIGHUP, WalSigHupHandler); /* set flag to read config file */
pqsignal(SIGINT, WalShutdownHandler); /* request shutdown */
pqsignal(SIGTERM, WalShutdownHandler); /* request shutdown */
pqsignal(SIGQUIT, wal_quickdie); /* hard crash time */
pqsignal(SIGALRM, SIG_IGN);
pqsignal(SIGPIPE, SIG_IGN);
pqsignal(SIGUSR1, SIG_IGN); /* reserve for ProcSignal */
pqsignal(SIGUSR2, SIG_IGN); /* not used */
/*
* Reset some signals that are accepted by postmaster but not here
*/
pqsignal(SIGCHLD, SIG_DFL);
pqsignal(SIGTTIN, SIG_DFL);
pqsignal(SIGTTOU, SIG_DFL);
pqsignal(SIGCONT, SIG_DFL);
pqsignal(SIGWINCH, SIG_DFL);
/* We allow SIGQUIT (quickdie) at all times */
sigdelset(&BlockSig, SIGQUIT);
/*
* Create a resource owner to keep track of our resources (not clear that
* we need this, but may as well have one).
*/
CurrentResourceOwner = ResourceOwnerCreate(NULL, "Wal Writer");
/*
* Create a memory context that we will do all our work in. We do this so
* that we can reset the context during error recovery and thereby avoid
* possible memory leaks. Formerly this code just ran in
* TopMemoryContext, but resetting that would be a really bad idea.
*/
walwriter_context = AllocSetContextCreate(TopMemoryContext,
"Wal Writer",
ALLOCSET_DEFAULT_MINSIZE,
ALLOCSET_DEFAULT_INITSIZE,
ALLOCSET_DEFAULT_MAXSIZE);
MemoryContextSwitchTo(walwriter_context);
/*
* If an exception is encountered, processing resumes here.
*
* This code is heavily based on bgwriter.c, q.v.
*/
if (sigsetjmp(local_sigjmp_buf, 1) != 0)
{
/* Since not using PG_TRY, must reset error stack by hand */
error_context_stack = NULL;
/* Prevent interrupts while cleaning up */
HOLD_INTERRUPTS();
/* Report the error to the server log */
EmitErrorReport();
/*
* These operations are really just a minimal subset of
* AbortTransaction(). We don't have very many resources to worry
* about in walwriter, but we do have LWLocks, and perhaps buffers?
*/
LWLockReleaseAll();
AbortBufferIO();
UnlockBuffers();
/* buffer pins are released here: */
ResourceOwnerRelease(CurrentResourceOwner,
RESOURCE_RELEASE_BEFORE_LOCKS,
false, true);
/* we needn't bother with the other ResourceOwnerRelease phases */
AtEOXact_Buffers(false);
AtEOXact_Files();
//.........这里部分代码省略.........
开发者ID:GisKook,项目名称:Gis,代码行数:101,代码来源:walwriter.c
示例17: nto_resume
static void
nto_resume (struct thread_resume *resume_info, size_t n)
{
/* We can only work in all-stop mode. */
procfs_status status;
procfs_run run;
int err;
TRACE ("%s\n", __func__);
/* Workaround for aliasing rules violation. */
sigset_t *run_fault = (sigset_t *) (void *) &run.fault;
nto_set_thread (resume_info->thread);
run.flags = _DEBUG_RUN_FAULT | _DEBUG_RUN_TRACE;
if (resume_info->kind == resume_step)
run.flags |= _DEBUG_RUN_STEP;
run.flags |= _DEBUG_RUN_ARM;
sigemptyset (run_fault);
sigaddset (run_fault, FLTBPT);
sigaddset (run_fault, FLTTRACE);
sigaddset (run_fault, FLTILL);
sigaddset (run_fault, FLTPRIV);
sigaddset (run_fault, FLTBOUNDS);
sigaddset (run_fault, FLTIOVF);
sigaddset (run_fault, FLTIZDIV);
sigaddset (run_fault, FLTFPE);
sigaddset (run_fault, FLTPAGE);
sigaddset (run_fault, FLTSTACK);
sigaddset (run_fault, FLTACCESS);
sigemptyset (&run.trace);
if (resume_info->sig)
{
int signal_to_pass;
devctl (nto_inferior.ctl_fd, DCMD_PROC_STATUS, &status, sizeof (status),
|
请发表评论