本文整理汇总了C++中sigset函数的典型用法代码示例。如果您正苦于以下问题:C++ sigset函数的具体用法?C++ sigset怎么用?C++ sigset使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sigset函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: main
int main (int argc, char * argv[])
{
/*Set up some Variables*/
int parent_PCB_id = argc;
int fid;
caddr_t mmap_ptr;
inputbuf *in_mem_p;
char c[MAX_CHAR];
// If parent tells us to terminate, then clean up first
sigset(SIGINT,in_die);
//Gets id of parents (to signal) and the file id of mmap.
sscanf(argv[1], "%d", &parent_PCB_id);
sscanf(argv[2], "%d", &kfid );
kmmap_ptr =
mmap((caddr_t) 0,
bufsize,
PROT_READ | PROT_WRITE,
MAP_SHARED,
kfid,
(off_t) 0);
if (kmmap_ptr == MAP_FAILED){
printf("Child memory map has failed, KB is aborting! Error <%s> ...\n", strerror(errno));
in_die(0);
}
in_mem_p = (inputbuf *) kmmap_ptr;
buf_index = 0;
in_mem_p->flag = MEM_EMPTY; // Set the flag to “Buffer Empty”
do {
fgets(c, MAX_CHAR, stdin); // This only returns when <cr> is pressed
strcpy(in_mem_p->data, c); // Read in data from buffer
in_mem_p->flag = MEM_FULL; // Set the flag
kill(parent_PCB_id ,SIGUSR1); // Signal the parent
buf_index = 0;
while(in_mem_p->flag == MEM_FULL){
usleep(100000); // Sleep until the RTX has read the data
}
} while(1); // Loops Forever
}
开发者ID:jjmaxwell4,项目名称:RTOS,代码行数:43,代码来源:keyboard.c
示例2: main
int main()
{
struct sigaction act;
act.sa_flags = 0;
act.sa_handler = myhandler;
sigemptyset(&act.sa_mask);
if (sigaction(SIGUSR1, &act, 0) != 0) {
perror("Unexpected error while using sigaction()");
return PTS_UNRESOLVED;
}
if (sigset(SIGUSR1,SIG_DFL) != myhandler) {
printf("Test FAILED: sigset didn't return myhandler even though it was SIGUSR1's original disposition\n");
return PTS_FAIL;
}
return PTS_PASS;
}
开发者ID:chathhorn,项目名称:posixtestsuite,代码行数:19,代码来源:9-1.c
示例3: _tt_sigset
/*
* _tt_sigset sets up a signal handler in such a way that the handler
* is *not* unregistered when the signal handler is entered. If
* returns 0 if an error occurs, else 1, and leaves errno set according
* to the underlying system call (sigaction, signal, sigset.)
*/
int
_tt_sigset(
int sig,
SIG_PF handler )
{
#if defined(OPT_POSIX_SIGNAL)
/*
* There seems to be some controversy over the type of sa_handler in
* C++ programs. Everybody\'s man page seems to say it is of type
* "void (*)()", and that\'s what Solaris does, and I think that\'s what
* POSIX says, but both HP and IBM define it as the arguably much more
* useful "void (*)(int)", a/k/a SIG_PF.
*
* [4 Apr 95] Solaris 2.5 has switched to use void (*)(int), which
* is nice for the long run but causes us some short-run problems
* as we want this level of the source to compile both on
* Solaris 2.4 and Solaris 2.5 for a while. To solve this, we use
* the "sa_sigaction" element of the sigaction structure, which is the
* three-argument flavor of the function pointer. This is, strictly,
* a lie, but it's safe since our signal handlers never look at the
* arguments anyway. sa_sigaction is, fortunately, the same on all
* Solaris versions.
* Once the requirement to compile on Solaris 2.4 goes away, we can
* simply remove the OPT_BUG_SUNOS_5 ifdefs here, leaving only the
* UnixWare one.
*/
struct sigaction act;
#if defined(OPT_BUG_SUNOS_5)
act.sa_sigaction = (void (*)(int, siginfo_t *, void *)) handler;
#elif defined(OPT_BUG_USL) || defined(OPT_BUG_UXP)
act.sa_handler = (void (*)()) handler;
#else
act.sa_handler = handler;
#endif
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
return 0==sigaction(sig, &act, NULL);
#elif defined(OPT_BSD_SIGNAL)
return SIG_ERR!=signal(sig, handler);
#else
return SIG_ERR!=sigset(sig, handler);
#endif
}
开发者ID:juddy,项目名称:edcde,代码行数:49,代码来源:tt_port.C
示例4: main
int
main(int argc, char * argv[])
{
if(argc!=2)
{
printf("usage: sleep <sleep in seconds>\n");
printf("used to test sleep() and sending a alarm signal -14 affects process\n");
printf("the signal will wakeup a process doing sleep and should return");
printf(" number of seconds left to sleep\n");
exit(0);
}
// set the alaram signal
//
sigset(SIGALRM, SIG_IGN);
unsigned int sleepTime = atoi(argv[1]);
unsigned int timeSlept;
time_t currTime = time(NULL);
struct tm currStruct;
localtime_r(&currTime, &currStruct);
printf("current time: %s\n", asctime(&currStruct));
timeSlept = sleepTime;
while ((timeSlept = sleep(timeSlept)) != 0)
{
// woke up early
//
printf("woke up early need to sleep: %u more\n", timeSlept);
currTime = time(NULL);
localtime_r(&currTime, &currStruct);
printf("current time: %s\n", asctime(&currStruct));
}
currTime = time(NULL);
localtime_r(&currTime, &currStruct);
printf("end time: %s\n", asctime(&currStruct));
return 0;
}
开发者ID:pp7462-git,项目名称:sandbox,代码行数:43,代码来源:sleep.cpp
示例5: pipeback_shell_close
void pipeback_shell_close (FILE *file)
{
#ifndef NOCLDWAIT
int wait_status = 0;
#endif
int cresult = fclose (file);
if (cresult) fprintf (stderr, "Warning. Error closing pipeback file.\n");
if (0 == --Usage)
{
if (SIG_ERR == sigset (SIGCHLD, SIG_DFL))
{
fprintf (stderr,
"Warning. Error resetting SIGCHLD action after pipeback.\n");
}
#ifndef NOCLDWAIT
wait (&wait_status);
#endif
}
}
开发者ID:syumprc,项目名称:solar-eclipse,代码行数:19,代码来源:pipeback.c
示例6: setup
static void setup(void)
{
char wdbuf[MAXPATHLEN];
/*
* Make a directory to do this in; ignore error if already exists.
* Save starting directory.
*/
tst_tmpdir();
if (getcwd(homedir, sizeof(homedir)) == NULL) {
tst_brkm(TBROK | TERRNO, NULL, "getcwd() failed");
}
parent_pid = getpid();
if (!fuss[0])
sprintf(fuss, "%s/ftest03.%d", getcwd(wdbuf, sizeof(wdbuf)),
getpid());
mkdir(fuss, 0755);
if (chdir(fuss) < 0) {
tst_resm(TBROK, "\tCan't chdir(%s), error %d.", fuss, errno);
tst_exit();
}
/*
* Default values for run conditions.
*/
iterations = 10;
nchild = 5;
csize = K_2; /* should run with 1, 2, and 4 K sizes */
max_size = K_1 * K_1;
misc_intvl = 10;
if (sigset(SIGTERM, term) == SIG_ERR) {
perror("sigset failed");
tst_resm(TBROK, " sigset failed: signo = 15");
tst_exit();
}
}
开发者ID:MohdVara,项目名称:ltp,代码行数:42,代码来源:ftest03.c
示例7: main
int main(void)
{
char buf[LINE_LEN];
pid_t pid;
int status;
if(sigset(SIGINT, sigint)== SIG_ERR)
perror("sigint");
printf("->:");
for(;;)
{
while(fgets(buf,LINE_LEN,stdin)!=NULL)
{
if(*buf != '\0')
buf[strlen(buf)-1]='\0';
printf("->:");
continue;
}
switch (pid = fork()){
case -1:
perror("fork failed");
break;
case 0:
execlp(buf,buf,NULL);
perror("cannot execlp");
break;
default :
if(waitpid(pid,&status,0)==-1)
perror("waitpid");
break;
}
printf("->:");
if(errno != EINTR)
break;
errno = 0;
}
return (0);
}
开发者ID:DontL,项目名称:ssp,代码行数:42,代码来源:sspsh2.c
示例8: doinput
void
doinput()
{
char ibuf[BUFSIZ];
int cc;
(void) fclose(fscript);
sigset(SIGWINCH, sigwinch);
while ((cc = read(0, ibuf, BUFSIZ)) != 0) {
if (cc == -1) {
if (errno == EINTR) { /* SIGWINCH probably */
continue;
} else {
break;
}
}
(void) write(master, ibuf, cc);
}
done();
}
开发者ID:AlainODea,项目名称:illumos-gate,代码行数:21,代码来源:script.c
示例9: main
int main()
{
sigset_t mask;
sigemptyset(&mask);
sigprocmask(SIG_SETMASK, &mask, NULL);
if (sigset(SIGCHLD, myhandler) == SIG_ERR) {
perror("Unexpected error while using sigset()");
return PTS_UNRESOLVED;
}
raise(SIGCHLD);
sigprocmask(SIG_SETMASK, NULL, &mask);
if (is_empty(&mask) != 1) {
printf("Test FAILED: signal mask should be empty\n");
return PTS_FAIL;
}
return PTS_PASS;
}
开发者ID:chathhorn,项目名称:posixtestsuite,代码行数:21,代码来源:5-1.c
示例10: returnTest2
static int
returnTest2 (void)
{
sighandler_t prev;
printf ("\n===== TEST 2 =====\n");
printf ("About to use sigset() to set SIG_HOLD\n");
prev = sigset (TEST_SIG, SIG_HOLD);
if (prev == SIG_ERR)
error (1, errno, "sigset");
printf ("Previous disposition: ");
printDisposition (prev);
printf (" (should be SIG_DFL)\n");
if (prev != SIG_DFL)
{
printf("TEST FAILED!!!\n");
return 1;
}
return 0;
} /* returnTest2 */
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.toolchain,代码行数:22,代码来源:tst-sigset2.c
示例11: ktrsigaction
static void
ktrsigaction(const struct sigaction *sa)
{
/*
* note: ktrstruct() has already verified that sa points to a
* buffer exactly sizeof(struct sigaction) bytes long.
*/
printf("struct sigaction { ");
if (sa->sa_handler == SIG_DFL)
printf("handler=SIG_DFL");
else if (sa->sa_handler == SIG_IGN)
printf("handler=SIG_IGN");
else if (sa->sa_flags & SA_SIGINFO)
printf("sigaction=%p", (void *)sa->sa_sigaction);
else
printf("handler=%p", (void *)sa->sa_handler);
printf(", mask=");
sigset(sa->sa_mask);
printf(", flags=");
sigactionflagname(sa->sa_flags);
printf(" }\n");
}
开发者ID:SylvestreG,项目名称:bitrig,代码行数:22,代码来源:ktrstruct.c
示例12: BSP_Reset
void BSP_Reset(void)
{
pid_t pid = getpid();
char cmdline_file[200];
char cmdline[1024];
int cfd, r;
snprintf(cmdline_file, 200, CMDLINE_FILE, pid);
cfd = open(cmdline_file, O_RDONLY);
if (cfd < 0) {
printf("Reboot failed: Cannot access %s: %s\n", cmdline_file, strerror(errno));
exit(2);
}
r = read(cfd, cmdline, 1024);
if (r < 0) {
printf("Reboot failed: Cannot read cmdline from proc file\n");
exit(2);
}
printf("############ Rebooting...\n\n\n");
sigset(SIGALRM, SIG_IGN);
execl(cmdline, cmdline, NULL);
}
开发者ID:UNIVERSAL-IT-SYSTEMS,项目名称:fossa-demo,代码行数:22,代码来源:sandbox.c
示例13: init
static void init(void)
{
int fd;
char wdbuf[MAXPATHLEN];
parent_pid = getpid();
tst_tmpdir();
/*
* Make a filename for the test.
*/
if (!filename[0])
sprintf(filename, "%s/ftest08.%d", getcwd(wdbuf, MAXPATHLEN),
getpid());
fd = open(filename, O_RDWR | O_CREAT | O_TRUNC, 0666);
if (fd < 0) {
tst_resm(TBROK, "Error %d creating file %s", errno, filename);
tst_exit();
}
close(fd);
/*
* Default values for run conditions.
*/
iterations = 10;
nchild = 5;
csize = K_2; /* should run with 1, 2, and 4 K sizes */
max_size = K_1 * K_1;
misc_intvl = 10;
if (sigset(SIGTERM, term) == SIG_ERR) {
tst_brkm(TBROK | TERRNO, NULL, "first sigset failed");
}
}
开发者ID:Altiscale,项目名称:sig-core-t_ltp,代码行数:38,代码来源:ftest08.c
示例14: main
int main(void)
{
sigset_t pendingset;
struct sigaction act;
act.sa_handler = myhandler;
act.sa_flags = 0;
sigemptyset(&act.sa_mask);
int rc;
rc = sigaction(SIGCHLD, &act, 0);
if (rc) {
ERR_MSG("sigaction()", rc);
return PTS_UNRESOLVED;
}
if (sigset(SIGCHLD, SIG_HOLD) == SIG_ERR) {
perror("Unexpected error while using sigset()");
return PTS_UNRESOLVED;
}
raise(SIGCHLD);
rc = sigpending(&pendingset);
if (rc) {
ERR_MSG("sigpending()", rc);
return PTS_UNRESOLVED;
}
if (sigismember(&pendingset, SIGCHLD) != 1) {
printf("Test FAILED: Signal SIGCHLD wasn't hold.\n");
return PTS_FAIL;
}
printf("Test PASSED\n");
return PTS_PASS;
}
开发者ID:kraj,项目名称:ltp,代码行数:36,代码来源:6-1.c
示例15: main
int /* O - Exit status */
main(int argc, /* I - Number of command-line arguments (6 or 7) */
char *argv[]) /* I - Command-line arguments */
{
const char *device_uri; /* Device URI */
char scheme[255], /* Scheme in URI */
hostname[1024], /* Hostname */
username[255], /* Username info (not used) */
resource[1024], /* Resource info (not used) */
*options, /* Pointer to options */
*name, /* Name of option */
*value, /* Value of option */
sep; /* Option separator */
int print_fd; /* Print file */
int copies; /* Number of copies to print */
time_t start_time; /* Time of first connect */
#ifdef __APPLE__
time_t current_time, /* Current time */
wait_time; /* Time to wait before shutting down socket */
#endif /* __APPLE__ */
int contimeout; /* Connection timeout */
int waiteof; /* Wait for end-of-file? */
int port; /* Port number */
char portname[255]; /* Port name */
int delay; /* Delay for retries... */
int device_fd; /* AppSocket */
int error; /* Error code (if any) */
http_addrlist_t *addrlist, /* Address list */
*addr; /* Connected address */
char addrname[256]; /* Address name */
int snmp_fd, /* SNMP socket */
start_count, /* Page count via SNMP at start */
page_count, /* Page count via SNMP */
have_supplies; /* Printer supports supply levels? */
ssize_t bytes = 0, /* Initial bytes read */
tbytes; /* Total number of bytes written */
char buffer[1024]; /* Initial print buffer */
#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
struct sigaction action; /* Actions for POSIX signals */
#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
/*
* Make sure status messages are not buffered...
*/
setbuf(stderr, NULL);
/*
* Ignore SIGPIPE signals...
*/
#ifdef HAVE_SIGSET
sigset(SIGPIPE, SIG_IGN);
#elif defined(HAVE_SIGACTION)
memset(&action, 0, sizeof(action));
action.sa_handler = SIG_IGN;
sigaction(SIGPIPE, &action, NULL);
#else
signal(SIGPIPE, SIG_IGN);
#endif /* HAVE_SIGSET */
/*
* Check command-line...
*/
if (argc == 1)
{
printf("network socket \"Unknown\" \"%s\"\n",
_cupsLangString(cupsLangDefault(), _("AppSocket/HP JetDirect")));
return (CUPS_BACKEND_OK);
}
else if (argc < 6 || argc > 7)
{
_cupsLangPrintf(stderr,
_("Usage: %s job-id user title copies options [file]"),
argv[0]);
return (CUPS_BACKEND_FAILED);
}
/*
* If we have 7 arguments, print the file named on the command-line.
* Otherwise, send stdin instead...
*/
if (argc == 6)
{
print_fd = 0;
copies = 1;
}
else
{
/*
* Try to open the print file...
*/
if ((print_fd = open(argv[6], O_RDONLY)) < 0)
{
_cupsLangPrintError("ERROR", _("Unable to open print file"));
return (CUPS_BACKEND_FAILED);
//.........这里部分代码省略.........
开发者ID:AnotherView,项目名称:cups,代码行数:101,代码来源:socket.c
示例16: main
//.........这里部分代码省略.........
* Allocate the buffer to hold the RIPng packet. In reality, it will be
* smaller than IPV6_MAX_PACKET octets due to (at least) the IPv6 and
* UDP headers but IPV6_MAX_PACKET is a convenient size.
*/
packet = (char *)malloc(IPV6_MAX_PACKET);
if (packet == NULL) {
syslog(LOG_ERR, "main: malloc: %m");
exit(EXIT_FAILURE);
}
msg = (struct rip6 *)packet;
/*
* Allocate the buffer to hold the ancillary data. This data is used to
* insure that the incoming hop count of a RIPCMD6_RESPONSE message is
* IPV6_MAX_HOPS which indicates that it came from a direct neighbor
* (namely, no intervening router decremented it).
*/
control = (char *)malloc(IPV6_MAX_PACKET);
if (control == NULL) {
syslog(LOG_ERR, "main: malloc: %m");
exit(EXIT_FAILURE);
}
openlog("in.ripngd", LOG_PID | LOG_CONS, LOG_DAEMON);
(void) gettimeofday(&now, (struct timezone *)NULL);
initifs();
solicitall(&allrouters);
if (supplier)
supplyall(&allrouters, 0, (struct interface *)NULL, _B_TRUE);
(void) sigset(SIGALRM, (void (*)(int))timer);
(void) sigset(SIGHUP, (void (*)(int))initifs);
(void) sigset(SIGTERM, (void (*)(int))term);
(void) sigset(SIGUSR1, (void (*)(int))if_dump);
(void) sigset(SIGUSR2, (void (*)(int))rtdump);
/*
* Seed the pseudo-random number generator for GET_RANDOM().
*/
srandom((uint_t)gethostid());
timer();
for (;;) {
if (needupdate) {
waittime = nextmcast;
timevalsub(&waittime, &now);
if (waittime.tv_sec < 0) {
timeout = 0;
} else {
timeout = TIME_TO_MSECS(waittime);
}
if (tracing & ACTION_BIT) {
(void) fprintf(ftrace,
"poll until dynamic update in %d msec\n",
timeout);
(void) fflush(ftrace);
}
} else {
timeout = INFTIM;
}
if ((n = poll(poll_ifs, poll_ifs_num, timeout)) < 0) {
开发者ID:andreiw,项目名称:polaris,代码行数:67,代码来源:main.c
示例17: main
//.........这里部分代码省略.........
case 't' : /* Test the cupsd.conf file... */
TestConfigFile = 1;
fg = 1;
break;
default : /* Unknown option */
_cupsLangPrintf(stderr, _("cupsd: Unknown option \"%c\" - "
"aborting."), *opt);
usage(1);
break;
}
else
{
_cupsLangPrintf(stderr, _("cupsd: Unknown argument \"%s\" - aborting."),
argv[i]);
usage(1);
}
if (!ConfigurationFile)
cupsdSetString(&ConfigurationFile, CUPS_SERVERROOT "/cupsd.conf");
/*
* If the user hasn't specified "-f", run in the background...
*/
if (!fg)
{
/*
* Setup signal handlers for the parent...
*/
#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */
sigset(SIGUSR1, parent_handler);
sigset(SIGCHLD, parent_handler);
sigset(SIGHUP, SIG_IGN);
#elif defined(HAVE_SIGACTION)
memset(&action, 0, sizeof(action));
sigemptyset(&action.sa_mask);
sigaddset(&action.sa_mask, SIGUSR1);
action.sa_handler = parent_handler;
sigaction(SIGUSR1, &action, NULL);
sigaction(SIGCHLD, &action, NULL);
sigemptyset(&action.sa_mask);
action.sa_handler = SIG_IGN;
sigaction(SIGHUP, &action, NULL);
#else
signal(SIGUSR1, parent_handler);
signal(SIGCLD, parent_handler);
signal(SIGHUP, SIG_IGN);
#endif /* HAVE_SIGSET */
if (fork() > 0)
{
/*
* OK, wait for the child to startup and send us SIGUSR1 or to crash
* and the OS send us SIGCHLD... We also need to ignore SIGHUP which
* might be sent by the init script to restart the scheduler...
*/
for (; parent_signal == 0;)
sleep(1);
开发者ID:ChErePOdaViLka,项目名称:cups,代码行数:66,代码来源:main.c
示例18: cupsdStartProcess
int /* O - Process ID or 0 */
cupsdStartProcess(
const char *command, /* I - Full path to command */
char *argv[], /* I - Command-line arguments */
char *envp[], /* I - Environment */
int infd, /* I - Standard input file descriptor */
int outfd, /* I - Standard output file descriptor */
int errfd, /* I - Standard error file descriptor */
int backfd, /* I - Backchannel file descriptor */
int sidefd, /* I - Sidechannel file descriptor */
int root, /* I - Run as root? */
void *profile, /* I - Security profile to use */
cupsd_job_t *job, /* I - Job associated with process */
int *pid) /* O - Process ID */
{
int i; /* Looping var */
const char *exec_path = command; /* Command to be exec'd */
char *real_argv[110], /* Real command-line arguments */
cups_exec[1024], /* Path to "cups-exec" program */
user_str[16], /* User string */
group_str[16], /* Group string */
nice_str[16]; /* FilterNice string */
uid_t user; /* Command UID */
cupsd_proc_t *proc; /* New process record */
#if USE_POSIX_SPAWN
posix_spawn_file_actions_t actions; /* Spawn file actions */
posix_spawnattr_t attrs; /* Spawn attributes */
sigset_t defsignals; /* Default signals */
#elif defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
struct sigaction action; /* POSIX signal handler */
#endif /* USE_POSIX_SPAWN */
#if defined(__APPLE__)
char processPath[1024], /* CFProcessPath environment variable */
linkpath[1024]; /* Link path for symlinks... */
int linkbytes; /* Bytes for link path */
#endif /* __APPLE__ */
*pid = 0;
/*
* Figure out the UID for the child process...
*/
if (RunUser)
user = RunUser;
else if (root)
user = 0;
else
user = User;
/*
* Check the permissions of the command we are running...
*/
if (_cupsFileCheck(command, _CUPS_FILE_CHECK_PROGRAM, !RunUser,
cupsdLogFCMessage, job ? job->printer : NULL))
return (0);
#if defined(__APPLE__)
if (envp)
{
/*
* Add special voodoo magic for OS X - this allows OS X programs to access
* their bundle resources properly...
*/
if ((linkbytes = readlink(command, linkpath, sizeof(linkpath) - 1)) > 0)
{
/*
* Yes, this is a symlink to the actual program, nul-terminate and
* use it...
*/
linkpath[linkbytes] = '\0';
if (linkpath[0] == '/')
snprintf(processPath, sizeof(processPath), "CFProcessPath=%s",
linkpath);
else
snprintf(processPath, sizeof(processPath), "CFProcessPath=%s/%s",
dirname((char *)command), linkpath);
}
else
snprintf(processPath, sizeof(processPath), "CFProcessPath=%s", command);
envp[0] = processPath; /* Replace <CFProcessPath> string */
}
#endif /* __APPLE__ */
/*
* Use helper program when we have a sandbox profile...
*/
#if !USE_POSIX_SPAWN
if (profile)
#endif /* !USE_POSIX_SPAWN */
{
snprintf(cups_exec, sizeof(cups_exec), "%s/daemon/cups-exec", ServerBin);
snprintf(user_str, sizeof(user_str), "%d", user);
//.........这里部分代码省略.........
开发者ID:Cacauu,项目名称:cups,代码行数:101,代码来源:process.c
示例19: main
int
main(int argc, char **argv)
{
int c;
int err;
const char *ofields = NULL;
ofmt_status_t ofmterr;
ofmt_field_t *fields = NULL;
uint_t ofmtflags = 0;
ipmp_handle_t ih;
ipmp_qcontext_t qcontext = IPMP_QCONTEXT_SNAP;
ipmpstat_cbfunc_t *cbfunc;
ipmpstat_walker_t *walker;
char errbuf[OFMT_BUFSIZE];
if ((progname = strrchr(argv[0], '/')) == NULL)
progname = argv[0];
else
progname++;
(void) setlocale(LC_ALL, "");
(void) textdomain(TEXT_DOMAIN);
while ((c = getopt(argc, argv, "nLPo:agipt")) != EOF) {
if (fields != NULL && strchr("agipt", c) != NULL)
die("only one output format may be specified\n");
switch (c) {
case 'n':
opt |= IPMPSTAT_OPT_NUMERIC;
break;
case 'L':
/* Undocumented option: for testing use ONLY */
qcontext = IPMP_QCONTEXT_LIVE;
break;
case 'P':
opt |= IPMPSTAT_OPT_PARSABLE;
ofmtflags |= OFMT_PARSABLE;
break;
case 'o':
ofields = optarg;
break;
case 'a':
walker = walk_addr;
cbfunc = info_output_cbfunc;
fields = addr_fields;
break;
case 'g':
walker = walk_group;
cbfunc = info_output_cbfunc;
fields = group_fields;
break;
case 'i':
walker = walk_if;
cbfunc = info_output_cbfunc;
fields = if_fields;
break;
case 'p':
fields = probe_fields;
break;
case 't':
walker = walk_if;
cbfunc = targinfo_output_cbfunc;
fields = targ_fields;
break;
default:
usage();
break;
}
}
if (argc > optind || fields == NULL)
usage();
/*
* Open a handle to the formatted output engine.
*/
ofmterr = ofmt_open(ofields, fields, ofmtflags, IPMPSTAT_NCOL, &ofmt);
if (ofmterr != OFMT_SUCCESS) {
/*
* If some fields were badly formed in human-friendly mode, we
* emit a warning and continue. Otherwise exit immediately.
*/
(void) ofmt_strerror(ofmt, ofmterr, errbuf, sizeof (errbuf));
if (ofmterr != OFMT_EBADFIELDS || (opt & IPMPSTAT_OPT_PARSABLE))
die("%s\n", errbuf);
else
warn("%s\n", errbuf);
}
/*
* Obtain the window size and monitor changes to the size. This data
* is used to redisplay the output headers when necessary.
*/
(void) sigset(SIGWINCH, sighandler);
if ((err = ipmp_open(&ih)) != IPMP_SUCCESS)
die_ipmperr(err, "cannot create IPMP handle");
if (ipmp_ping_daemon(ih) != IPMP_SUCCESS)
//.........这里部分代码省略.........
开发者ID:AlainODea,项目名称:illumos-gate,代码行数:101,代码来源:ipmpstat.c
示例20: registerSignalToHandle
void registerSignalToHandle(int sig) {
/* Register the new action to handle the signal sig. */
CHECK(sigset(sig, signalHandler));
}
开发者ID:wnr,项目名称:os13-lab2,代码行数:4,代码来源:main.c
注:本文中的sigset函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论