123456789101112131415161718192021222324252627282930 |
- #include <stdio.h>
- #include <stdlib.h>
- #include "test_helpers.h"
- int main(void) {
- FILE *f = fopen("stdio/stdio.in", "r");
- ERROR_IF(fopen, f, == NULL);
- flockfile(f);
-
-
- if (!ftrylockfile(f)) {
- puts("Mutex unlocked but it shouldn't be");
- exit(EXIT_FAILURE);
- }
- funlockfile(f);
- if (ftrylockfile(f)) {
- puts("Mutex locked but it shouldn't be");
- exit(EXIT_FAILURE);
- }
- if (!ftrylockfile(f)) {
- puts("Mutex unlocked but it shouldn't be");
- exit(EXIT_FAILURE);
- }
- funlockfile(f);
- }
|