Ticket #356: _response.c

File _response.c, 959 bytes (added by KO Myung-Hun, 9 years ago)

testcase

Line 
1#include <stdio.h>
2#include <string.h>
3#include <process.h>
4
5#define LINE_LENGTH ( 1000 * 1000 )
6
7#define RESPONSE_NAME "_response.rsp"
8
9static void spawn( const char *prog )
10{
11 FILE *f;
12 int i;
13
14 f = fopen( RESPONSE_NAME, "wt");
15
16 for( i = 0; i < LINE_LENGTH - 1; i++ )
17 fputc('X', f );
18 fputc('0', f );
19 fputc('\n', f );
20
21 for( i = 0; i < LINE_LENGTH - 1; i++ )
22 fputc('X', f );
23 fputc('1', f );
24
25 fclose( f );
26
27 spawnlp( P_WAIT, prog, prog, "@" RESPONSE_NAME, NULL );
28
29 remove( RESPONSE_NAME );
30}
31
32int main( int argc, char *argv[])
33{
34 _response( &argc, &argv );
35
36 if( argc > 1 )
37 {
38 int i;
39
40 for( i = 0; i < argc; i++ )
41 printf("a length of argv[%d] = %d, the last char = %c\n",
42 i, strlen( argv[ i ]), argv[ i ][ strlen( argv[ i ]) - 1 ]);
43
44 return 0;
45 }
46
47 spawn( argv[ 0 ]);
48
49 return 0;
50}