mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-18 06:03:42 +03:00
[PATCH] udevd - kill the lockfile
This commit is contained in:
parent
aca29aa51f
commit
d2cf99df7d
1
Makefile
1
Makefile
@ -241,7 +241,6 @@ udev_version.h:
|
||||
@echo \#define UDEV_PERMISSION_FILE \"$(configdir)\udev.permissions\" >> $@
|
||||
@echo \#define UDEV_BIN \"$(DESTDIR)$(sbindir)/udev\" >> $@
|
||||
@echo \#define UDEVD_BIN \"$(DESTDIR)$(sbindir)/udevd\" >> $@
|
||||
@echo \#define UDEVD_LOCK \"$(udevdir)/\.udevd.lock\" >> $@
|
||||
|
||||
# config files automatically generated
|
||||
GEN_CONFIGS = $(LOCAL_CFG_DIR)/udev.conf
|
||||
|
@ -34,7 +34,6 @@
|
||||
#include "logging.h"
|
||||
#include "namedev.h"
|
||||
#include "udevdb.h"
|
||||
#include "libsysfs/libsysfs.h"
|
||||
|
||||
static int delete_path(char *path)
|
||||
{
|
||||
|
29
udevd.c
29
udevd.c
@ -21,7 +21,6 @@
|
||||
|
||||
#include <pthread.h>
|
||||
#include <stddef.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
@ -30,7 +29,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
@ -324,7 +322,6 @@ static void sig_handler(int signum)
|
||||
switch (signum) {
|
||||
case SIGINT:
|
||||
case SIGTERM:
|
||||
unlink(UDEVD_LOCK);
|
||||
exit(20 + signum);
|
||||
break;
|
||||
default:
|
||||
@ -332,28 +329,6 @@ static void sig_handler(int signum)
|
||||
}
|
||||
}
|
||||
|
||||
static int one_and_only(void)
|
||||
{
|
||||
char string[50];
|
||||
int lock_file;
|
||||
|
||||
lock_file = open(UDEVD_LOCK, O_RDWR | O_CREAT, 0x640);
|
||||
if (lock_file < 0)
|
||||
return -1;
|
||||
|
||||
/* see if we can lock */
|
||||
if (lockf(lock_file, F_TLOCK, 0) < 0) {
|
||||
dbg("file is already locked, exit");
|
||||
close(lock_file);
|
||||
return -1;
|
||||
}
|
||||
|
||||
snprintf(string, sizeof(string), "%d\n", getpid());
|
||||
write(lock_file, string, strlen(string));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int ssock;
|
||||
@ -369,10 +344,6 @@ int main(int argc, char *argv[])
|
||||
|
||||
init_logging("udevd");
|
||||
|
||||
/* only let one version of the daemon run at any one time */
|
||||
if (one_and_only() != 0)
|
||||
exit(0);
|
||||
|
||||
signal(SIGINT, sig_handler);
|
||||
signal(SIGTERM, sig_handler);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user