aboutsummaryrefslogtreecommitdiffstats
path: root/src/tools/ttytest.c
blob: a449bf9ba3e3528d7401107fcd1e5657c8429863 (plain) (blame)
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
28
29
30
31
32
33
34
35
36
#define _XOPEN_SOURCE 600
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>

int main(void) {
	int fdm;
	int rc;

	// initial
	system("ls -l /dev/pts");

	fdm = posix_openpt(O_RDWR);
	if (fdm < 0) {
		perror("posix_openpt");
		return 1;
	}

	rc = grantpt(fdm);
	if (rc != 0) {
		perror("grantpt");
		return 1;
	}

	rc = unlockpt(fdm);
	if (rc != 0) {
		perror("unlockpt");
		return 1;
	}

	// final
	system("ls -l /dev/pts");

	return 0;
}