mirror of
https://github.com/yrutschle/sslh.git
synced 2025-04-15 00:20:34 +03:00
check return values (fix #61)
This commit is contained in:
parent
ed48d3964f
commit
0cde3d794a
16
common.c
16
common.c
@ -821,14 +821,24 @@ void drop_privileges(const char* user_name, const char* chroot_path)
|
|||||||
void write_pid_file(const char* pidfile)
|
void write_pid_file(const char* pidfile)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
int res;
|
||||||
|
|
||||||
f = fopen(pidfile, "w");
|
f = fopen(pidfile, "w");
|
||||||
if (!f) {
|
if (!f) {
|
||||||
perror(pidfile);
|
print_message(msg_system_error, "write_pid_file:%s:%s", pidfile, strerror(errno));
|
||||||
exit(3);
|
exit(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(f, "%d\n", getpid());
|
res = fprintf(f, "%d\n", getpid());
|
||||||
fclose(f);
|
if (res < 0) {
|
||||||
|
print_message(msg_system_error, "write_pid_file:fprintf:%s", strerror(errno));
|
||||||
|
exit(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
res = fclose(f);
|
||||||
|
if (res == EOF) {
|
||||||
|
print_message(msg_system_error, "write_pid_file:fclose:%s", strerror(errno));
|
||||||
|
exit(3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user