| 13 | | return NSApplicationMain(argc, (const char **) argv); |
|---|
| | 17 | int fp = open(lockPath, O_CREAT | O_EXCL); |
|---|
| | 18 | if(fp = -1) |
|---|
| | 19 | { |
|---|
| | 20 | struct stat lockfile; |
|---|
| | 21 | time_t current = time(NULL); |
|---|
| | 22 | if(stat(lockPath, &lockfile)) |
|---|
| | 23 | { |
|---|
| | 24 | if(lockfile.st_ctimespec.tv_sec + 60*60 > current) //Only pay attention to lock file if it is no more than an hour old |
|---|
| | 25 | { |
|---|
| | 26 | unlink(lockPath); |
|---|
| | 27 | fp = open(lockPath, O_CREAT | O_EXCL | O_EXLOCK); |
|---|
| | 28 | } |
|---|
| | 29 | } |
|---|
| | 30 | } |
|---|
| | 31 | if(fp == -1) |
|---|
| | 32 | return 0; |
|---|
| | 33 | |
|---|
| | 34 | int ret = NSApplicationMain(argc, (const char **) argv); |
|---|
| | 35 | |
|---|
| | 36 | unlink(lockPath); |
|---|
| | 37 | |
|---|
| | 38 | return ret; |
|---|