mariadb/linux/tests/test-flock.c
Yoni Fogel 324c278a31 Addresses #2257 refs[t:2257] Merge windows port back into main.
git-svn-id: file:///svn/toku/tokudb@16673 c7de825b-a66e-492c-adef-691d508d4ae1
2013-04-16 23:58:56 -04:00

28 lines
573 B
C

#include <stdio.h>
#include <toku_assert.h>
#include <errno.h>
#include <unistd.h>
#include <sys/wait.h>
#include "toku_portability.h"
int main(void) {
int fd = toku_os_lock_file(__FILE__);
assert(fd != -1);
pid_t pid = fork();
assert(pid != -1);
if (pid == 0) {
int fd2 = toku_os_lock_file(__FILE__);
assert(fd2 == -1);
return 0;
} else {
int status;
pid_t wpid = waitpid(-1, &status, 0);
assert(wpid == pid);
assert(status == 0);
}
int r = toku_os_unlock_file(fd);
assert(r == 0);
return 0;
}