File: ptyalloc.c

package info (click to toggle)
ytalk 3.3.0-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 760 kB
  • ctags: 570
  • sloc: ansic: 6,105; sh: 474; makefile: 99
file content (36 lines) | stat: -rw-r--r-- 460 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
28
29
30
31
32
33
34
35
36
/* ptyalloc.c
 *
 * Test the pseudo-terminal allocation methods in YTalk.
 */

#include "config.h"
#include <stdio.h>

int getpty();

#ifdef HAVE_OPENPTY
int openpty();
#endif

int main() {

	char buf[128];
	int fd, fds;
	int g = 0, o = 0;

	fd = getpty(buf);
	if (fd < 0)
		g++;

#ifdef HAVE_OPENPTY
	if (openpty(&fd, &fds, buf, 0, 0) < 0)
#endif
		o++;

	if (g && o) {
		fprintf(stderr, "Both getpty() and openpty() failed.\n");
		return 1;
	}

	return 0;
}