The R Project SVN R

Rev

Rev 53611 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
53594 ripley 1
#include <stdlib.h>
2
#include <stdio.h>
53611 ripley 3
#include <string.h>
53594 ripley 4
 
72823 kalibera 5
#ifdef _WIN32 /* for sleep function */
6
 
7
#include <windows.h>
8
 
9
void mysleep(int sec) {
10
    Sleep((DWORD)sec * 1000);
11
}
12
 
13
#else /* Unix/POSIX */
14
 
15
#include <unistd.h>
16
 
17
void mysleep(int sec) {
18
    /* could use nanosleep, but on Solaris it needs -lrt  */
19
    sleep(sec);
20
}
21
#endif
22
 
53594 ripley 23
int main(int argc, char* argv[])
24
{
25
    int status = 0;
26
    char line[1000];
27
 
28
    printf("stdout 1\n"); fflush(stdout);
29
    fprintf(stderr, "stderr 1\n");
30
    fflush(stderr);
31
 
53611 ripley 32
    if (argc > 1 && strcmp(argv[1], "1") == 0) {
53594 ripley 33
	while(fgets(line, 1000, stdin)) printf("stdin: %s", line);
34
	fflush(stdout);
35
    }
53611 ripley 36
    if (argc > 1 && strcmp(argv[1], "1")) {
72823 kalibera 37
	status = atoi(argv[1]);
53611 ripley 38
    }
72823 kalibera 39
    if (argc > 1 && strcmp(argv[1], "infinite_loop") == 0) {
40
	printf("Going to infinite loop...\n");
41
	fflush(stdout);
42
	while(1); /* infinite loop */
43
    }
44
    if (argc > 2 && strcmp(argv[1], "sleep") == 0) {
45
	int sec = atoi(argv[2]);
46
	printf("Sleeping for %d seconds...\n", sec);
47
	fflush(stdout);
48
	mysleep(sec);
49
	printf("Done sleeping for %d seconds.\n", sec);
50
	fflush(stdout);
51
    }
53594 ripley 52
 
53
    exit(status);
54
}