本文整理汇总了C++中arguments::tracer方法的典型用法代码示例。如果您正苦于以下问题:C++ arguments::tracer方法的具体用法?C++ arguments::tracer怎么用?C++ arguments::tracer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arguments
的用法示例。
在下文中一共展示了arguments::tracer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ERRORPRINTF
int
main (int ac, char *ag[])
{
int index;
pth_init ();
argp_parse (&argp, ac, ag, ARGP_IN_ORDER, &index, &arg);
// if you ever want this to be fatal, doing it here would be too late
if (getuid () == 0)
ERRORPRINTF (arg.tracer(), E_WARNING | 20, 0, "EIBD should not run as root");
signal (SIGPIPE, SIG_IGN);
if (arg.daemon)
{
int fd = open (arg.daemon, O_WRONLY | O_APPEND | O_CREAT, FILE_MODE);
if (fd == -1)
die ("Can not open file %s", arg.daemon);
int i = fork ();
if (i < 0)
die ("fork failed");
if (i > 0)
exit (0);
close (1);
close (2);
close (0);
dup2 (fd, 1);
dup2 (fd, 2);
close (fd);
setsid ();
}
FILE *pidf;
if (arg.pidfile)
if ((pidf = fopen (arg.pidfile, "w")) != NULL)
{
fprintf (pidf, "%d", getpid ());
fclose (pidf);
}
signal (SIGINT, SIG_IGN);
signal (SIGTERM, SIG_IGN);
// main loop
#ifdef HAVE_SYSTEMD
sd_notify(0,"READY=1");
#endif
int sig;
if (! arg.stop_now)
do {
sigset_t t1;
sigemptyset (&t1);
sigaddset (&t1, SIGINT);
sigaddset (&t1, SIGHUP);
sigaddset (&t1, SIGTERM);
pth_sigwait (&t1, &sig);
if (sig == SIGHUP && arg.daemon)
{
int fd =
open (arg.daemon, O_WRONLY | O_APPEND | O_CREAT, FILE_MODE);
if (fd == -1)
{
ERRORPRINTF (arg.tracer(), E_ERROR | 21, 0, "can't open log file %s",
arg.daemon);
continue;
}
close (1);
close (2);
dup2 (fd, 1);
dup2 (fd, 2);
close (fd);
}
} while (sig == SIGHUP);
#ifdef HAVE_SYSTEMD
sd_notify(0,"STOPPING=1");
#endif
signal (SIGINT, SIG_DFL);
signal (SIGTERM, SIG_DFL);
#ifdef HAVE_GROUPCACHE
DeleteGroupCache ();
#endif
arg.free_l3();
if (arg.pidfile)
unlink (arg.pidfile);
pth_yield (0);
pth_yield (0);
pth_yield (0);
pth_yield (0);
pth_exit (0);
return 0;
//.........这里部分代码省略.........