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

Function read_lock_pid

lockfile.c:138–162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136}
137
138static int read_lock_pid(const char *pid_path, uintmax_t *pid_out)
139{
140 struct strbuf content = STRBUF_INIT;
141 const char *val;
142 int ret = -1;
143
144 if (strbuf_read_file(&content, pid_path, LOCK_PID_MAXLEN) <= 0)
145 goto out;
146
147 strbuf_rtrim(&content);
148
149 if (skip_prefix(content.buf, "pid ", &val)) {
150 char *endptr;
151 *pid_out = strtoumax(val, &endptr, 10);
152 if (*pid_out > 0 && !*endptr)
153 ret = 0;
154 }
155
156 if (ret)
157 warning(_("malformed lock pid file '%s'"), pid_path);
158
159out:
160 strbuf_release(&content);
161 return ret;
162}
163
164/* Make sure errno contains a meaningful value on error */
165static int lock_file(struct lock_file *lk, const char *path, int flags,

Callers 1

unable_to_lock_messageFunction · 0.85

Calls 4

strbuf_read_fileFunction · 0.85
strbuf_rtrimFunction · 0.85
warningFunction · 0.85
strbuf_releaseFunction · 0.85

Tested by

no test coverage detected