File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111 */
1212
1313#include "builtin.h"
14+ #include "tempfile.h"
1415#include "lockfile.h"
1516#include "parse-options.h"
1617#include "run-command.h"
@@ -42,20 +43,7 @@ static struct argv_array prune = ARGV_ARRAY_INIT;
4243static struct argv_array prune_worktrees = ARGV_ARRAY_INIT ;
4344static struct argv_array rerere = ARGV_ARRAY_INIT ;
4445
45- static char * pidfile ;
46-
47- static void remove_pidfile (void )
48- {
49- if (pidfile )
50- unlink (pidfile );
51- }
52-
53- static void remove_pidfile_on_signal (int signo )
54- {
55- remove_pidfile ();
56- sigchain_pop (signo );
57- raise (signo );
58- }
46+ static struct tempfile pidfile ;
5947
6048static void git_config_date_string (const char * key , const char * * output )
6149{
@@ -201,7 +189,7 @@ static const char *lock_repo_for_gc(int force, pid_t* ret_pid)
201189 int fd ;
202190 char * pidfile_path ;
203191
204- if (pidfile )
192+ if (is_tempfile_active ( & pidfile ) )
205193 /* already locked */
206194 return NULL ;
207195
@@ -248,11 +236,8 @@ static const char *lock_repo_for_gc(int force, pid_t* ret_pid)
248236 write_in_full (fd , sb .buf , sb .len );
249237 strbuf_release (& sb );
250238 commit_lock_file (& lock );
251-
252- pidfile = pidfile_path ;
253- sigchain_push_common (remove_pidfile_on_signal );
254- atexit (remove_pidfile );
255-
239+ register_tempfile (& pidfile , pidfile_path );
240+ free (pidfile_path );
256241 return NULL ;
257242}
258243
You can’t perform that action at this time.
0 commit comments