#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Go to the source code of this file.
◆ Crash()
Definition at line 19 of file process_test.cc.
19 {
20 int* segfault = nullptr;
21 *segfault = 1;
22}
◆ main()
int main |
( |
int |
argc, |
|
|
char * |
argv[] |
|
) |
| |
Definition at line 31 of file process_test.cc.
31 {
32 if (argc != 5) {
33 fprintf(stderr,
34 "./process_test <outstream> <echocount> <exitcode> <crash>\n");
36 }
37
38 int outstream = atoi(
argv[1]);
39 if (outstream < 0 || outstream > 2) {
40 fprintf(stderr, "unknown outstream");
42 }
43
44 int echo_counter = 0;
45 int echo_count = atoi(
argv[2]);
46 int exit_code = atoi(
argv[3]);
47 int crash = atoi(
argv[4]);
48
49 if (crash == 1) {
51 }
52
53 const int kLineSize = 128;
55
56 while ((echo_count != echo_counter) &&
57 (fgets(
line, kLineSize, stdin) !=
nullptr)) {
58 if (outstream == 0) {
59 fprintf(stdout,
"%s",
line);
60 fflush(stdout);
61 } else if (outstream == 1) {
62 fprintf(stderr,
"%s",
line);
63 fflush(stderr);
64 } else if (outstream == 2) {
65 fprintf(stdout,
"%s",
line);
66 fprintf(stderr,
"%s",
line);
67 fflush(stdout);
68 fflush(stderr);
69 }
70 echo_counter++;
71 }
72
73 return exit_code;
74}