Skip to content

Commit 5e734fc

Browse files
committed
Fix compile error in one of the runpipe tests with some gcc versions.
1 parent 061d77f commit 5e734fc

File tree

1 file changed

+11
-2
lines changed
  • judge/runpipe_test/S_closes_stdin

1 file changed

+11
-2
lines changed

judge/runpipe_test/S_closes_stdin/judge.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
1+
#define _XOPEN_SOURCE 700
2+
13
#include <stdio.h>
24
#include <signal.h>
5+
#include <unistd.h>
6+
#include <time.h>
37

48
int main() {
59
signal(SIGPIPE, SIG_IGN);
610

7-
usleep(500000);
11+
struct timespec req = {0};
12+
req.tv_nsec = 500000000L; // 0.5 seconds
13+
nanosleep(&req, NULL);
14+
815
printf("123\n");
916
fflush(stdout);
1017
int x;
11-
scanf("%d", &x);
18+
if (scanf("%d", &x) != 1) {
19+
return 1;
20+
}
1221
if (x == 42)
1322
return 42;
1423
return 43;

0 commit comments

Comments
 (0)