Debian Codegraph @

src/posix_cgreen_pipe.c

raw symbols SCIP
1 #cxx . . $ `<file>/src/posix_cgreen_pipe.c`/include "cgreen/internal/cgreen_pipe.h"cxx . . $ `<file>/include/cgreen/internal/cgreen_pipe.h`/
2
3 #include "utils.h"cxx . . $ `<file>/src/utils.h`/
4
5 #include <errno.h>
6 #include <fcntl.h>
7 #include <signal.h>
8 #include <stdio.h>
9 #include <unistd.h>
10 #include <sys/wait.h>
11
12 #ifdef __ANDROID__
13 #include "cgreen/internal/android_headers/androidcompat.h"
14 #endif // #ifdef __ANDROID__
15
16 #ifndef O_NONBLOCKcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:62:10`!
17 # error "Your platform does not support POSIX ASYNC pipe reads. Please report a bug to http://github.com/cgreen-devs/cgreen/issues"
18 /* One way to do it the old way is: ioctl(fd, FIOBIO, &flags); */
19 #endif
20
21
22 int cgreen_pipe_opencxx . . $ cgreen_pipe_open(a5f7824ee4986326).(int pipes[2])
23 {
24 int pipe_open_result;
25 int pipe_nonblock_result;
26
27 pipe_open_result = pipecxx . . $ pipe(a5f7824ee4986326).(pipes);
28
29 if (pipe_open_result != 0) {
30 return pipe_open_result;
31 }
32
33 pipe_nonblock_result = fcntlcxx . . $ fcntl(cac4efb70f20a0fb).(pipes[1], F_SETFLcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:169:9`!, O_NONBLOCKcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:62:10`!);
34
35 if (pipe_nonblock_result != 0) {
36 return pipe_open_result;
37 }
38
39 return 0;
40 }
41
42 void cgreen_pipe_closecxx . . $ cgreen_pipe_close(d4f767463ce0a6b3).(int p)
43 {
44 closecxx . . $ close(7864480464b09eea).(p);
45 }
46
47 ssize_tcxx . . $ ssize_t# cgreen_pipe_readcxx . . $ cgreen_pipe_read(7e34d0a36f355389).(int p, void *buf, size_t count)
48 {
49 if (0 != fcntlcxx . . $ fcntl(cac4efb70f20a0fb).(p, F_SETFLcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:169:9`!, O_NONBLOCKcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:62:10`!)) {
50 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!, "could not set file status flag on read pipe\n");
51 return -1;
52 }
53
54 return readcxx . . $ read(7e34d0a36f355389).(p, buf, count);
55 }
56
57 ssize_tcxx . . $ ssize_t# cgreen_pipe_writecxx . . $ cgreen_pipe_write(41184a59d38b4f65).(int p, const void *buf, size_t count)
58 {
59 int pipe_write_result = writecxx . . $ write(41184a59d38b4f65).(p, buf, count);
60 int status;
61 if (pipe_write_result < 0) {
62 if (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! == EWOULDBLOCKcxx . . $ `<external>/17922322188510340118/errno.h:22:9`!) {
63 PANICcxx . . $ `src/utils.h:14:9`!("Too many assertions within a single test.");
64 } else if (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! != EPIPEcxx . . $ `<external>/8987895939074593727/errno-base.h:36:9`!) {
65 PANICcxx . . $ `src/utils.h:14:9`!("Error when reporting from test case process to reporter.");
66 }
67 raisecxx . . $ raise(7864480464b09eea).(SIGPIPEcxx . . $ `<external>/11773118241360591791/signum-generic.h:60:9`!);
68 waitcxx . . $ wait(a5f7824ee4986326).(&status); /* Safe-guarding against a signalhandler for SIGPIPE, which
69 incidentally the test case for pipe block need to have... */
70 }
71 return pipe_write_result;
72 }
73
74 /* vim: set ts=4 sw=4 et cindent: */