Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions zhm/zhm.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,12 +414,13 @@ init_hm(void)
#ifndef DEBUG
if (!inetd && !nofork)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add { } to this statement? I don't like unblanaced if-else clauses where one has it and the other does not.

detach();

/* Write pid to file */
fp = fopen(PidFile, "w");
if (fp != NULL) {
else {
/* Write pid to file */
fp = fopen(PidFile, "w");
if (fp != NULL) {
fprintf(fp, "%d\n", getpid());
fclose(fp);
}
}
#endif /* DEBUG */

Expand Down Expand Up @@ -469,11 +470,18 @@ detach(void)
/* detach from terminal and fork. */
register int i, x = ZGetFD();
register long size;
FILE *fp;

i = fork();
if (i) {
if (i < 0)
perror("fork");
perror("fork");
/* Write pid to file */
fp = fopen(PidFile, "w");
if (fp != NULL) {
fprintf(fp, "%d\n", i);
fclose(fp);
}
exit(0);
}
#ifdef _POSIX_VERSION
Expand Down