MCPcopy Create free account
hub / github.com/ClusterLabs/pacemaker / crm_read_pidfile

Function crm_read_pidfile

lib/common/utils.c:1269–1295  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1267}
1268
1269static int
1270crm_read_pidfile(const char *filename)
1271{
1272 int fd;
1273 long pid = -1;
1274 char buf[LOCKSTRLEN + 1];
1275
1276 if ((fd = open(filename, O_RDONLY)) < 0) {
1277 goto bail;
1278 }
1279
1280 if (read(fd, buf, sizeof(buf)) < 1) {
1281 goto bail;
1282 }
1283
1284 if (sscanf(buf, "%lu", &pid) > 0) {
1285 if (pid <= 0) {
1286 pid = -ESRCH;
1287 }
1288 }
1289
1290 bail:
1291 if (fd >= 0) {
1292 close(fd);
1293 }
1294 return pid;
1295}
1296
1297static int
1298crm_pidfile_inuse(const char *filename, long mypid)

Callers 1

crm_make_daemonFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected