/* *Sleepforanamountoftimewhileregularlycheckingif *ourparentisstillalive.
*/ int check_sleep(int sleeptime, int flags)
{ int i; int interval = 5; staticint ppid = 0;
if (ppid == 0) ppid = getppid();
if (flags & L_INTERVAL_D_)
interval = 1;
for (i = 0; i < sleeptime; i += interval) {
sleep(interval); if (kill(ppid, 0) < 0 && errno == ESRCH) return L_ERROR;
} return0;
}
#ifdef MAXPATHLEN if (strlen(lockfile) >= MAXPATHLEN) { if (!quiet)
fprintf(stderr, "dotlockfile: %s: name too long\n", lockfile); return L_NAMELEN;
} #endif
/* *Checkifwerunsetgid.
*/ #ifdef MAILGROUP if (gid != egid) { /* *Seeiftherequestedlockisforamailbox. *First,remembercurrentworkingdirectory.
*/ #ifdef O_PATH
cwd_fd = open(".", O_PATH|O_CLOEXEC); #else
cwd_fd = open(".", O_RDONLY|O_CLOEXEC); #endif if (cwd_fd < 0) { if (!quiet)
fprintf(stderr, "dotlockfile: opening \".\": %s\n",
strerror(errno)); return L_ERROR;
} /* *Nowchangedirectorytothedirectorythelockfileisin.
*/ char *file, *dir;
r = fn_split(lockfile, &file, &dir); if (r != L_SUCCESS) { if (!quiet)
perror("dotlockfile"); return L_ERROR;
} if (chdir(dir) != 0) { if (!quiet)
fprintf(stderr, "dotlockfile: %s: %s\n", dir, strerror(errno)); return L_ERROR;
}
pid = fork(); if (pid < 0) { if (!quiet)
perror("fork");
lockfile_remove(lockfile); exit(L_ERROR);
} if (pid == 0) { /* drop setgid */ if (gid != egid && setgid(gid) < 0) {
perror("setgid"); exit(127);
} /* restore current working directory */ if (cwd_fd >= 0) { if (fchdir(cwd_fd) < 0) {
perror("dotlockfile: restoring cwd:"); exit(127);
}
close(cwd_fd);
} /* exec */
execvp(cmd[0], cmd);
perror(cmd[0]); exit(127);
}
/* wait for child */ while (1) { if (!writepid)
alarm(30);
e = waitpid(pid, &wstatus, 0); if (e >= 0 || errno != EINTR) break; if (!writepid)
lockfile_touch(lockfile);
}
alarm(0);
lockfile_remove(lockfile);
if (passthrough) { if (WIFEXITED(wstatus)) return WEXITSTATUS(wstatus); if (WIFSIGNALED(wstatus)) return128+WTERMSIG(wstatus);
} return0;
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.17 Sekunden
(vorverarbeitet am 2026-09-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.