mirror of
https://github.com/stefanberger/swtpm.git
synced 2026-01-13 19:09:39 +00:00
swtpm: remove pidfile after process exits
Remove the pidfile once swtpm process exits. Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
This commit is contained in:
parent
29cfd0a4fd
commit
e47bd065ff
@ -1237,6 +1237,8 @@ cleanup:
|
||||
if (exit_prg) {
|
||||
logprintf(STDOUT_FILENO,
|
||||
"CUSE TPM is shutting down.\n");
|
||||
pidfile_remove();
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
@ -94,3 +94,15 @@ int pidfile_write(pid_t pid)
|
||||
error:
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* pidfile_remove: Remove the pid file
|
||||
*
|
||||
*/
|
||||
void pidfile_remove(void)
|
||||
{
|
||||
if (!g_pidfile)
|
||||
return;
|
||||
|
||||
unlink(g_pidfile);
|
||||
}
|
||||
@ -40,5 +40,6 @@
|
||||
|
||||
int pidfile_set(const char *pidfile);
|
||||
int pidfile_write(pid_t pid);
|
||||
void pidfile_remove(void);
|
||||
|
||||
#endif /* _SWTPM_PIDFILE_H_ */
|
||||
|
||||
@ -322,6 +322,8 @@ int swtpm_main(int argc, char **argv, const char *prgname, const char *iface)
|
||||
TPMLIB_Terminate();
|
||||
}
|
||||
|
||||
pidfile_remove();
|
||||
|
||||
close(notify_fd[0]);
|
||||
notify_fd[0] = -1;
|
||||
close(notify_fd[1]);
|
||||
|
||||
@ -311,6 +311,8 @@ int swtpm_chardev_main(int argc, char **argv, const char *prgname, const char *i
|
||||
TPMLIB_Terminate();
|
||||
}
|
||||
|
||||
pidfile_remove();
|
||||
|
||||
close(notify_fd[0]);
|
||||
notify_fd[0] = -1;
|
||||
close(notify_fd[1]);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user