udhcp: use fdprintf for pidfile creation (smaller code)

This commit is contained in:
Denis Vlasenko 2007-03-14 21:54:42 +00:00
parent 9616aff095
commit 1ce190b7c1

View File

@ -52,15 +52,9 @@ int pidfile_acquire(const char *pidfile)
void pidfile_write_release(int pid_fd) void pidfile_write_release(int pid_fd)
{ {
FILE *out;
if (pid_fd < 0) return; if (pid_fd < 0) return;
out = fdopen(pid_fd, "w"); fdprintf(pid_fd, "%d\n", getpid());
if (out) {
fprintf(out, "%d\n", getpid());
fclose(out);
}
lockf(pid_fd, F_UNLCK, 0); lockf(pid_fd, F_UNLCK, 0);
close(pid_fd); close(pid_fd);
} }