include stdio include stdlib include pthread include readline readline

 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
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <readline/readline.h>
#include <readline/history.h>
void *threadFunc (void *arg) {
int i = 0;
while (1) {
if (i > 5) break;
printf ("Azaza\n");
sleep (1);
i ++;
}
}
int main() {
pthread_t pth;
pthread_create (&pth, NULL, threadFunc, "processing...");
while (1) {
char *l;
l = readline ("> ");
if (l == NULL) {
break;
}
if (*l) {
add_history (l);
printf ("%s\n", l);
}
free (l);
}
return 0;
}