X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/c6b81a9865b49f39f7d388ac64a8d74ce414081e..9b73d1c0e9ca979700493337d0a87497b882d811:/cleanup.c diff --git a/cleanup.c b/cleanup.c index 57fce18f..ee2fa4d5 100644 --- a/cleanup.c +++ b/cleanup.c @@ -29,6 +29,7 @@ static char *cleanup_new_fname; static struct file_struct *cleanup_file; static int cleanup_fd1, cleanup_fd2; static struct map_struct *cleanup_buf; +static int cleanup_pid = 0; void exit_cleanup(int code) { @@ -50,6 +51,15 @@ void exit_cleanup(int code) if (code) { kill_all(SIGUSR1); } + if ((cleanup_pid != 0) && (cleanup_pid == (int) getpid())) { + char *pidf = lp_pid_file(); + if (pidf && *pidf) { + unlink(lp_pid_file()); + } + } + + if (code) log_exit(code); + exit(code); } @@ -70,3 +80,8 @@ void cleanup_set(char *fnametmp, char *fname, struct file_struct *file, cleanup_fd1 = fd1; cleanup_fd2 = fd2; } + +void cleanup_set_pid(int pid) +{ + cleanup_pid = pid; +}