mirror of
https://github.com/troglobit/finit.git
synced 2026-11-09 16:21:24 +00:00
pidfile_read(): Reindent.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
7f2c73468f
commit
939cfc2476
1 file changed
+20
-20
@@ -131,31 +131,31 @@ void ifconfig(char *ifname, char *addr, char *mask, int up)
|
|||||||
*/
|
*/
|
||||||
pid_t pidfile_read(char *pidfile)
|
pid_t pidfile_read(char *pidfile)
|
||||||
{
|
{
|
||||||
pid_t pid = 0;
|
pid_t pid = 0;
|
||||||
char buf[16];
|
char buf[16];
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
if (!pidfile) {
|
if (!pidfile) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fexist(pidfile))
|
if (!fexist(pidfile))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
fp = fopen(pidfile, "r");
|
fp = fopen(pidfile, "r");
|
||||||
if (!fp)
|
if (!fp)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (fgets(buf, sizeof(buf), fp)) {
|
if (fgets(buf, sizeof(buf), fp)) {
|
||||||
errno = 0;
|
errno = 0;
|
||||||
pid = (pid_t)strtol(buf, NULL, 10);
|
pid = (pid_t)strtol(buf, NULL, 10);
|
||||||
if (errno)
|
if (errno)
|
||||||
pid = 0; /* Failed conversion. */
|
pid = 0; /* Failed conversion. */
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
return pid;
|
return pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in new issue
Block a user