KNF
Formatter: knfmt 4.2.0 Signed-off-by: Masanori Ogino <mogino@acm.org>
This commit is contained in:
parent
6751cd55df
commit
18181c8b02
1 changed files with 34 additions and 38 deletions
22
main.c
22
main.c
|
|
@ -62,19 +62,18 @@ opening (void)
|
|||
|
||||
#ifdef LOCK_FILE
|
||||
|
||||
|
||||
int
|
||||
make_lockfile(void)
|
||||
{
|
||||
int fd;
|
||||
|
||||
fd = open(lock_file, O_CREAT | O_EXCL, 0600);
|
||||
if (fd < 0) return ERROR;
|
||||
if (fd < 0)
|
||||
return ERROR;
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
erase_lockfile(void)
|
||||
{
|
||||
|
|
@ -119,8 +118,7 @@ exec_fork (void)
|
|||
if (tmp < 0) {
|
||||
fprintf(stderr, "Can't fork child process\r\n");
|
||||
fflush(stderr);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
signal(SIGCHLD, _exit);
|
||||
signal(SIGHUP, SIG_IGN);
|
||||
signal(SIGINT, SIG_IGN);
|
||||
|
|
@ -134,7 +132,6 @@ exec_fork (void)
|
|||
|
||||
signal(SIGHUP, (void (*)())signal_handler);
|
||||
|
||||
|
||||
signal(SIGINT, (void (*)())terminate_handler);
|
||||
signal(SIGQUIT, (void (*)())signal_handler);
|
||||
signal(SIGTERM, (void (*)())terminate_handler);
|
||||
|
|
@ -142,8 +139,6 @@ exec_fork (void)
|
|||
signal(SIGTSTP, SIG_IGN);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
leave_tty(void)
|
||||
{
|
||||
|
|
@ -155,7 +150,8 @@ leave_tty (void)
|
|||
kill(getppid(), SIGTERM);
|
||||
fclose(stdin);
|
||||
fclose(stdout);
|
||||
if (!tmp) fclose(stderr);
|
||||
if (!tmp)
|
||||
fclose(stderr);
|
||||
|
||||
if (fork_flag) {
|
||||
if ((tmp = open("/dev/tty", O_RDWR)) >= 0) {
|
||||
|
|
@ -166,15 +162,14 @@ leave_tty (void)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
opening();
|
||||
#ifndef __NetBSD__
|
||||
if (setuid(geteuid())) {
|
||||
fprintf(stderr, "error at setuid.\r\n"); exit(1);
|
||||
fprintf(stderr, "error at setuid.\r\n");
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -184,7 +179,8 @@ main (int argc, char **argv)
|
|||
|
||||
#ifdef LOCK_FILE
|
||||
if (make_lockfile() == ERROR) {
|
||||
fprintf(stderr, "Already running...\r\n"); exit(1);
|
||||
fprintf(stderr, "Already running...\r\n");
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue