repo.or.cz
/
glibc.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
(ptrace) [PTRACE_TRACEME]: Notify the proc server that we are now traced.
[glibc.git]
/
manual
/
examples
/
popen.c
blob
16ae32fa166caf5a51ec8c4f3ac89501e8d41f75
1
#include <stdio.h>
2
#include <stdlib.h>
3
4
void
5
write_data
(
FILE
*
stream
)
6
{
7
int
i
;
8
for
(
i
=
0
;
i
<
100
;
i
++)
9
fprintf
(
stream
,
"%d
\n
"
,
i
);
10
if
(
ferror
(
stream
))
11
{
12
fprintf
(
stderr
,
"Output to stream failed.
\n
"
);
13
exit
(
EXIT_FAILURE
);
14
}
15
}
16
17
/*@group*/
18
int
19
main
(
void
)
20
{
21
FILE
*
output
;
22
23
output
=
popen
(
"more"
,
"w"
);
24
if
(!
output
)
25
{
26
fprintf
(
stderr
,
"Could not run more.
\n
"
);
27
return
EXIT_FAILURE
;
28
}
29
write_data
(
output
);
30
pclose
(
output
);
31
return
EXIT_SUCCESS
;
32
}
33
/*@end group*/