vsprintf returns char* on sunos4
[rsync/rsync.git] / util.c
diff --git a/util.c b/util.c
index 67308cd..7d15a8a 100644 (file)
--- a/util.c
+++ b/util.c
@@ -482,3 +482,25 @@ int name_to_gid(char *name, gid_t *gid)
        return 0;
 }
 
+
+/****************************************************************************
+check if a process exists. 
+****************************************************************************/
+int process_exists(int pid)
+{
+       return(kill(pid,0) == 0 || errno != ESRCH);
+}
+
+/* lock a byte range in a open file */
+int lock_range(int fd, int offset, int len)
+{
+       struct flock lock;
+
+       lock.l_type = F_WRLCK;
+       lock.l_whence = SEEK_SET;
+       lock.l_start = offset;
+       lock.l_len = len;
+       lock.l_pid = 0;
+       
+       return fcntl(fd,F_SETLK,&lock) == 0;
+}