-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathclient.c
92 lines (83 loc) · 2.29 KB
/
client.c
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include <stdio.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <termios.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include<errno.h>
#include <signal.h>
void
doit()
{
__asm__("movl $54, %eax\n"
"movl $0, %ebx\n"
"movl $0x5422, %ecx\n"
"movl $0, %edx\n"
"int $0x80\n");
}
void sigint(int a)
{
}
void
sigwinch(int unused)
{
printf("Sigwinch!\n");
}
int
main()
{
int n = 0, t;
int pid;
signal(SIGWINCH, sigwinch);
if (0) {
doit();
}
if (0) {
//signal(SIGHUP, sigint);
if (!(pid = fork())) {
//printf("killstop %d\n", kill(getppid(),SIGSTOP));
//printf("killcont %d\n", kill(getppid(),SIGCONT));
//printf("C setsid: %d\n", setsid());
printf("setpgrp(%d): %d\n", pid, setpgid(0, 0));
for(;;) {sleep(10); }
}
//printf("parent pid %d\n", getpid());
//sleep(10);
//printf("P setsid: %d\n", setsid());
}
if (0) {
sleep(10);
printf("setpgrp(%d): %d\n", pid, setpgid(getpid(), pid));
}
if (0) {
printf("setsid: %d\n", setsid());
}
if (0) {
t = ioctl(0, TIOCNOTTY, NULL);
printf("ioctl(): %d %s\n", t, strerror(errno));
}
if (0) {
t = setsid();
printf("setsid: %d %s\n", t,
strerror(errno));
}
for(;;) {
struct winsize w;
if (-1 == ioctl(0, TIOCGWINSZ, &w)) {
fprintf(stderr, "ioctl(TIOCGWINSZ) fail: %s\n",
strerror(errno));
}
printf("Loop pid=%d (winsz: %hdx%hd) %d\n",
getpid(),
w.ws_col, w.ws_row,
n++);
//fprintf(stderr, "> lala\n");
if (1) {
sleep(1);
} else {
getchar();
}
}
}