Add contrib.
[doldaconnect.git] / config / locktouch.c
CommitLineData
d3372da9 1#include <stdlib.h>
2#include <unistd.h>
3#include <fcntl.h>
4#include <stdio.h>
5#include <errno.h>
6
7int main(int argc, char **argv)
8{
9 int fd;
10
11 if(argc < 2)
12 {
13 fprintf(stderr, "usage: locktouch lockfile\n");
14 exit(1);
15 }
16 if((fd = open(argv[1], O_CREAT | O_EXCL, 0666)) < 0)
17 {
18 if(errno != EEXIST)
19 {
20 perror(argv[1]);
21 exit(2);
22 }
23 exit(1);
24 }
25 close(fd);
26 return(0);
27}