Advanced Programming in the UNIX® Environment
ptg10805159 Section 13.3 Coding Rules 467 terminal device, there is nowherefor output to be displayed, nor is there anywhere to ...
ptg10805159 468 Daemon Processes Chapter 13 sa.sa_flags = 0; if (sigaction(SIGHUP, &sa, NULL) < 0) err_quit("%s: can’t ig ...
ptg10805159 Section 13.4 Error Logging 469 We can also usepsto verify that no active process exists with ID 13799. This means th ...
ptg10805159 470 Daemon Processes Chapter 13 Thereare three ways to generate log messages: Kernelroutines can call thelogfunctio ...
ptg10805159 Section 13.4 Error Logging 471 option XSI Description LOG_CONS • If the log message can’t be sent tosyslogdvia the U ...
ptg10805159 472 Daemon Processes Chapter 13 facility XSI Description LOG_AUDIT the audit facility LOG_AUTH authorization program ...
ptg10805159 Section 13.5 Single-Instance Daemons 473 you might need to define an additional symbol, such as__BSD_VISIBLEon FreeB ...
ptg10805159 474 Daemon Processes Chapter 13 int already_running(void) { int fd; char buf[16]; fd = open(LOCKFILE, O_RDWR|O_CREAT ...
ptg10805159 Section 13.6 Daemon Conventions 475 •Ifthe daemon supports configuration options, they areusually stored in/etc. The ...
ptg10805159 476 Daemon Processes Chapter 13 } switch (signo) { case SIGHUP: syslog(LOG_INFO, "Re-reading configuration file"); r ...
ptg10805159 Section 13.6 Daemon Conventions 477 sigfillset(&mask); if ((err = pthread_sigmask(SIG_BLOCK, &mask, NULL)) ! ...
ptg10805159 478 Daemon Processes Chapter 13 } void sigterm(int signo) { syslog(LOG_INFO, "got SIGTERM; exiting"); exit(0); } voi ...
ptg10805159 Section 13.7 Client–Server Model 479 sigaddset(&sa.sa_mask, SIGTERM); sa.sa_flags = 0; if (sigaction(SIGHUP, &am ...
ptg10805159 480 Daemon Processes Chapter 13 #include "apue.h" #include <fcntl.h> int set_cloexec(int fd) { int val; if ((v ...
ptg10805159 14 Advanced I/O 14.1 Introduction This chapter covers numerous topics and functions that we lump under the term adva ...
ptg10805159 482 Advanced I/O Chapter 14 •Certainioctloperations •Some of the interprocess communication functions (Chapter 15) W ...
ptg10805159 Section 14.2 Nonblocking I/O 483 #include "apue.h" #include <errno.h> #include <fcntl.h> char buf[500000 ...
ptg10805159 484 Advanced I/O Chapter 14 $./a.out < /etc/services 2>stderr.out output to terminal lots of output to termina ...
ptg10805159 Section 14.3 RecordLocking 485 14.3 Record Locking What happens when two people edit the same file at the same time? ...
ptg10805159 486 Advanced I/O Chapter 14 fcntlRecordLocking Let’s repeat the prototype for thefcntlfunction from Section 3.14. #i ...
«
21
22
23
24
25
26
27
28
29
30
»
Free download pdf