}
// Returns fd
-int acquire_lock(void) {
+int flock_file(const char *lock_path) {
int r;
int lockfd = -1;
struct stat stab_fd;
struct stat stab_path;
- lock_path = m_asprintf("%s/l%s",run_base,ident);
-
for (;;) {
if (lockfd >= 0) { close(lockfd); lockfd = -1; }
return lockfd;
}
+// Returns fd
+int acquire_lock(void) {
+ lock_path = m_asprintf("%s/l%s",run_base,ident);
+ return flock_file(lock_path);
+}
+
static void shbang_opts(const char *const **argv_io,
const struct cmdinfo *cmdinfos) {
myopt(argv_io, cmdinfos);
void find_socket_path(void);
int acquire_lock(void);
+int flock_file(const char *lock_path);
extern const struct cmdinfo cmdinfos[];
#define PREFORK_CMDINFOS \