diff -Naur busybox.orig/include/libbb.h busybox/include/libbb.h
--- busybox.orig/include/libbb.h	2008-02-03 08:20:16 +0000
+++ busybox/include/libbb.h	2008-02-03 12:16:43 +0000
@@ -291,6 +291,7 @@
 void xpipe(int filedes[2]);
 off_t xlseek(int fd, off_t offset, int whence);
 off_t fdlength(int fd);
+int xmklock(const char *path);
 
 /* Useful for having small structure members/global variables */
 typedef int8_t socktype_t;
diff -Naur busybox.orig/libbb/xfuncs.c busybox/libbb/xfuncs.c
--- busybox.orig/libbb/xfuncs.c	2008-02-03 08:20:15 +0000
+++ busybox/libbb/xfuncs.c	2008-02-03 12:17:06 +0000
@@ -783,3 +783,28 @@
 		bb_perror_msg_and_die("ioctl %#x failed", request);
 }
 #endif
+
+int xmklock(const char *path)
+{
+	int sfd;
+	static char *lock_file;
+
+	void rmlock(void)
+	{
+		unlink(lock_file);
+	}
+
+	sfd = open(path, O_CREAT | O_WRONLY | O_TRUNC | O_EXCL, 0644);
+	if (sfd < 0) {
+		if (errno == EEXIST)
+			bb_perror_msg_and_die("can't lock");
+		if (ENABLE_FEATURE_CLEAN_UP)
+			free((char *)path);
+	} else {
+		if (ENABLE_FEATURE_CLEAN_UP)
+			free(lock_file);
+		lock_file = (char *)path;
+		atexit(rmlock);
+	}
+	return sfd;
+}
