File: blockingtest.c

package info (click to toggle)
tinyssh 20230101-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,244 kB
  • sloc: ansic: 12,106; sh: 1,168; python: 479; makefile: 42
file content (27 lines) | stat: -rw-r--r-- 566 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*
20140302
Jan Mojzis
Public domain.
*/

#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include "fail.h"
#include "blocking.h"

int main(void) {

    int pi[2];
    long long i;

    if (pipe(pi) == -1) fail("failure");
    for (i = 0; i < 2; ++i) {
        if ((fcntl(pi[i], F_GETFL) & O_NONBLOCK) != 0) fail("failure");
        blocking_disable(pi[i]);
        if ((fcntl(pi[i], F_GETFL) & O_NONBLOCK) == 0) fail("failure");
        blocking_enable(pi[i]);
        if ((fcntl(pi[i], F_GETFL) & O_NONBLOCK) != 0) fail("failure");
    }
    _exit(0);
}