MCPcopy Index your code
hub / github.com/git/git / create_lock_pid_file

Function create_lock_pid_file

lockfile.c:109–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107}
108
109static struct tempfile *create_lock_pid_file(const char *pid_path, int mode)
110{
111 struct strbuf content = STRBUF_INIT;
112 struct tempfile *pid_tempfile = NULL;
113 int fd;
114
115 if (!lockfile_pid_enabled)
116 goto out;
117
118 fd = open(pid_path, O_WRONLY | O_CREAT | O_EXCL, mode);
119 if (fd < 0)
120 goto out;
121
122 strbuf_addf(&content, "pid %" PRIuMAX "\n", (uintmax_t)getpid());
123 if (write_in_full(fd, content.buf, content.len) < 0) {
124 warning_errno(_("could not write lock pid file '%s'"), pid_path);
125 close(fd);
126 unlink(pid_path);
127 goto out;
128 }
129
130 close(fd);
131 pid_tempfile = register_tempfile(pid_path);
132
133out:
134 strbuf_release(&content);
135 return pid_tempfile;
136}
137
138static int read_lock_pid(const char *pid_path, uintmax_t *pid_out)
139{

Callers 1

lock_fileFunction · 0.85

Calls 5

strbuf_addfFunction · 0.85
write_in_fullFunction · 0.85
warning_errnoFunction · 0.85
register_tempfileFunction · 0.85
strbuf_releaseFunction · 0.85

Tested by

no test coverage detected