Lines Matching +full:parent +full:- +full:child
1 /*-
132 return -1; \
140 * Test 1 - F_GETLK on unlocked region
159 printf("1 - F_GETLK on unlocked region: "); in test1()
173 * Test 2 - F_SETLK on locked region
182 * We create a child process to hold the lock which we will in test2()
183 * test. We use a pipe to communicate with the child. in test2()
205 * We are the child. We set a write lock and then in test2()
206 * write one byte back to the parent to tell it. The in test2()
207 * parent will kill us when its done. in test2()
210 err(1, "F_SETLK (child)"); in test2()
212 err(1, "writing to pipe (child)"); in test2()
218 * Wait until the child has set its lock and then perform the in test2()
222 err(1, "reading from pipe (child)"); in test2()
225 * fcntl should return -1 with errno set to either EACCES or in test2()
228 printf("2 - F_SETLK on locked region: "); in test2()
241 * Test 3 - F_SETLKW on locked region
253 * We create a child process to hold the lock which we will in test3()
254 * test. We use a pipe to communicate with the child. in test3()
276 * We are the child. We set a write lock and then in test3()
277 * write one byte back to the parent to tell it. The in test3()
278 * parent will kill us when its done. in test3()
281 err(1, "F_SETLK (child)"); in test3()
283 err(1, "writing to pipe (child)"); in test3()
289 * Wait until the child has set its lock and then perform the in test3()
293 err(1, "reading from pipe (child)"); in test3()
296 * fcntl should wait until the alarm and then return -1 with in test3()
299 printf("3 - F_SETLKW on locked region: "); in test3()
315 * Test 4 - F_GETLK on locked region
323 * We create a child process to hold the lock which we will in test4()
324 * test. We use a pipe to communicate with the child. in test4()
345 * We are the child. We set a write lock and then in test4()
346 * write one byte back to the parent to tell it. The in test4()
347 * parent will kill us when its done. in test4()
350 err(1, "F_SETLK (child)"); in test4()
352 err(1, "writing to pipe (child)"); in test4()
358 * Wait until the child has set its lock and then perform the in test4()
362 err(1, "reading from pipe (child)"); in test4()
366 * made in the child process. in test4()
371 printf("4 - F_GETLK on locked region: "); in test4()
389 * Test 5 - F_SETLKW simple deadlock
400 * We create a child process to hold the lock which we will in test5()
401 * test. Because our test relies on the child process being in test5()
402 * blocked on the parent's lock, we can't easily use a pipe to in test5()
403 * synchronize so we just sleep in the parent to given the in test5()
404 * child a chance to setup. in test5()
406 * To create the deadlock condition, we arrange for the parent in test5()
407 * to lock the first byte of the file and the child to lock in test5()
408 * the second byte. After locking the second byte, the child in test5()
410 * block. The parent will then attempt to lock the second byte in test5()
411 * (owned by the child) which should cause deadlock. in test5()
418 * Lock the first byte in the parent. in test5()
425 err(1, "F_SETLK 1 (parent)"); in test5()
433 * Lock the second byte in the child and then block on in test5()
434 * the parent's lock. in test5()
438 err(1, "F_SETLK (child)"); in test5()
441 err(1, "F_SETLKW (child)"); in test5()
446 * Wait until the child has set its lock and then perform the in test5()
452 * fcntl should immediately return -1 with errno set to in test5()
457 printf("5 - F_SETLKW simple deadlock: "); in test5()
482 * Test 6 - F_SETLKW complex deadlock.
494 * Because our test relies on the child process being blocked in test6()
495 * on the parent's lock, we can't easily use a pipe to in test6()
496 * synchronize so we just sleep in the parent to given the in test6()
504 * Lock the first byte in the parent. in test6()
511 err(1, "F_SETLK 1 (parent)"); in test6()
520 * Lock the second byte in the child and then sleep in test6()
536 * Lock the third byte in the child and then block on in test6()
537 * the parent's lock. in test6()
555 * fcntl should immediately return -1 with errno set to in test6()
560 printf("6 - F_SETLKW complex deadlock: "); in test6()
588 * Test 7 - F_SETLK shared lock on exclusive locked region
597 * We create a child process to hold the lock which we will in test7()
598 * test. We use a pipe to communicate with the child. in test7()
620 * We are the child. We set a write lock and then in test7()
621 * write one byte back to the parent to tell it. The in test7()
622 * parent will kill us when its done. in test7()
625 err(1, "F_SETLK (child)"); in test7()
627 err(1, "writing to pipe (child)"); in test7()
633 * Wait until the child has set its lock and then perform the in test7()
637 err(1, "reading from pipe (child)"); in test7()
640 * fcntl should wait until the alarm and then return -1 with in test7()
643 printf("7 - F_SETLK shared lock on exclusive locked region: "); in test7()
659 * Test 8 - F_SETLK shared lock on share locked region
669 * We create a child process to hold the lock which we will in test8()
670 * test. We use a pipe to communicate with the child. in test8()
692 * We are the child. We set a write lock and then in test8()
693 * write one byte back to the parent to tell it. The in test8()
694 * parent will kill us when its done. in test8()
697 err(1, "F_SETLK (child)"); in test8()
699 err(1, "writing to pipe (child)"); in test8()
705 * Wait until the child has set its lock and then perform the in test8()
709 err(1, "reading from pipe (child)"); in test8()
712 * fcntl should wait until the alarm and then return -1 with in test8()
715 printf("8 - F_SETLK shared lock on share locked region: "); in test8()
737 * Test 9 - F_SETLK exclusive lock on share locked region
746 * We create a child process to hold the lock which we will in test9()
747 * test. We use a pipe to communicate with the child. in test9()
769 * We are the child. We set a write lock and then in test9()
770 * write one byte back to the parent to tell it. The in test9()
771 * parent will kill us when its done. in test9()
774 err(1, "F_SETLK (child)"); in test9()
776 err(1, "writing to pipe (child)"); in test9()
782 * Wait until the child has set its lock and then perform the in test9()
786 err(1, "reading from pipe (child)"); in test9()
789 * fcntl should wait until the alarm and then return -1 with in test9()
792 printf("9 - F_SETLK exclusive lock on share locked region: "); in test9()
808 * Test 10 - trying to set bogus pid or sysid values
818 * We create a child process to hold the lock which we will in test10()
819 * test. We use a pipe to communicate with the child. in test10()
844 * We are the child. We set a write lock and then in test10()
845 * write one byte back to the parent to tell it. The in test10()
846 * parent will kill us when its done. in test10()
849 err(1, "F_SETLK (child)"); in test10()
851 err(1, "writing to pipe (child)"); in test10()
857 * Wait until the child has set its lock and then perform the in test10()
861 err(1, "reading from pipe (child)"); in test10()
863 printf("10 - trying to set bogus pid or sysid values: "); in test10()
882 * Test 11 - remote locks
904 printf("11 - remote locks: "); in test11()
962 * Test 12 - F_SETLKW on locked region which is then unlocked
971 * We create a child process to hold the lock which we will in test12()
972 * test. We use a pipe to communicate with the child. in test12()
994 * We are the child. We set a write lock and then in test12()
995 * write one byte back to the parent to tell it. The in test12()
996 * parent will kill us when its done. in test12()
999 err(1, "F_SETLK (child)"); in test12()
1001 err(1, "writing to pipe (child)"); in test12()
1008 * Wait until the child has set its lock and then perform the in test12()
1012 err(1, "reading from pipe (child)"); in test12()
1015 * fcntl should wait until the alarm and then return -1 with in test12()
1018 printf("12 - F_SETLKW on locked region which is then unlocked: "); in test12()
1039 * Test 13 - F_SETLKW on locked region, race with owner
1048 * We create a child process to hold the lock which we will in test13()
1049 * test. We use a pipe to communicate with the child. in test13()
1059 printf("13 - F_SETLKW on locked region, race with owner: "); in test13()
1077 * We are the child. We set a write lock and then in test13()
1078 * write one byte back to the parent to tell it. The in test13()
1079 * parent will kill us when its done. in test13()
1082 err(1, "F_SETLK (child)"); in test13()
1084 err(1, "writing to pipe (child)"); in test13()
1091 * Wait until the child has set its lock and then perform the in test13()
1097 err(1, "reading from pipe (child)"); in test13()
1101 * fcntl should wait until the alarm and then return -1 with in test13()
1115 FAIL(!(res == 0 || (res == -1 && errno == EINTR))); in test13()
1127 * Test 14 - soak test
1134 * We create a set of child processes and let each one run in test14()
1151 printf("14 - soak test: "); in test14()
1164 * Parent - record the pid and continue. in test14()
1171 * Child - do some work and exit. in test14()
1188 len = end - start; in test14()
1242 * We got a write lock - write in test14()
1256 * We got a read lock - read in test14()
1314 * Test 15 - flock(2) semantcs
1324 * the other shared lock - there should be no active locks at this
1332 * We create a child process to hold the lock which we will in test15()
1333 * test. We use a pipe to communicate with the child. in test15()
1337 * set the child's shared lock. in test15()
1354 * We are the child. We set a shared lock and then in test15()
1355 * write one byte back to the parent to tell it. The in test15()
1356 * parent will kill us when its done. in test15()
1363 err(1, "fcntl(F_SETLK) (child)"); in test15()
1365 err(1, "writing to pipe (child)"); in test15()
1371 * Wait until the child has set its lock and then perform the in test15()
1375 err(1, "reading from pipe (child)"); in test15()
1382 * flock should wait until the alarm and then return -1 with in test15()
1385 printf("15 - flock(2) semantics: "); in test15()
1391 * Kill the child to force it to drop its locks. in test15()
1424 error = fcntl(tc->tc_fd, F_SETLKW, &tc->tc_fl); in test16_func()
1432 * Test 16 - F_SETLKW from two threads
1441 * We create a child process to hold the lock which we will in test16()
1442 * test. We use a pipe to communicate with the child. in test16()
1466 * We are the child. We set a write lock and then in test16()
1467 * write one byte back to the parent to tell it. The in test16()
1468 * parent will kill us when its done. in test16()
1471 err(1, "F_SETLK (child)"); in test16()
1473 err(1, "writing to pipe (child)"); in test16()
1479 * Wait until the child has set its lock and then perform the in test16()
1483 err(1, "reading from pipe (child)"); in test16()
1486 * fcntl should wait until the alarm and then return -1 with in test16()
1489 printf("16 - F_SETLKW on locked region by two threads: "); in test16()
1498 * Sleep, then kill the child. This makes me a little sad, but it's in test16()
1522 int intr; /* non-zero if the test interrupts a lock */
1562 test_argc = argc - 2; in main()