aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCalvin Morrison <mutantturkey@gmail.com>2014-04-13 20:30:17 -0400
committerCalvin Morrison <mutantturkey@gmail.com>2014-04-13 20:30:17 -0400
commit7b4f739fa7c1cc5ab14a60cc96d418d599d9f609 (patch)
tree57f0e48b137262935906875946be34aaee9b66aa
parent91ec2c60e80d4c2a81fc942185465954d91d5f7b (diff)
don't error check, that's up to the user, might actually be a featureHEADmaster
-rw-r--r--lock.c26
1 files changed, 7 insertions, 19 deletions
diff --git a/lock.c b/lock.c
index 871425d..9f6ceed 100644
--- a/lock.c
+++ b/lock.c
@@ -6,31 +6,19 @@
#include <sys/stat.h>
#include <stdlib.h>
-int try_mkdir(const char *dn) {
- int ret;
-
- errno = 0;
- ret = 0;
-
- ret = mkdir(dn, S_IRUSR);
- if(errno && errno != EEXIST) {
- fprintf(stderr, "Failed to create lock %s.\n", dn);
- exit(EXIT_FAILURE);
- }
- return ret;
-
-}
-
int main(int argc, char **argv){
- if(argc != 2){
+ if(argc != 2) {
fprintf(stderr, "Please supply one argument: the lock directory.\n");
return EXIT_FAILURE;
}
- /* create lock */
- if(try_mkdir(argv[1])){
+ if(mkdir(argv[1], S_IRUSR)) {
+ if(errno && errno != EEXIST) {
+ fprintf(stderr, "Failed to create lock %s.\n", argv[1]);
+ return EXIT_FAILURE;
+ }
/* lock exists */
- for(; try_mkdir(argv[1]); ){
+ for(; mkdir(argv[1], S_IRUSR); ) {
sleep(1);
}
}