Rizin
unix-like reverse engineering framework and cli tools
main.c
Go to the documentation of this file.
1
#include <stdio.h>
2
#include <string.h>
3
#include <inttypes.h>
4
5
#include <
uv.h
>
6
7
uv_loop_t
*
loop
;
8
uv_process_t
child_req
;
9
uv_process_options_t
options
;
10
11
void
on_exit
(
uv_process_t
*
req
,
int64_t
exit_status
,
int
term_signal) {
12
fprintf(stderr,
"Process exited with status %"
PRId64
", signal %d\n"
,
exit_status
, term_signal);
13
uv_close
((
uv_handle_t
*)
req
,
NULL
);
14
}
15
16
int
main
() {
17
loop
=
uv_default_loop
();
18
19
size_t
size
= 500;
20
char
path
[
size
];
21
uv_exepath
(
path
, &
size
);
22
strcpy(
path
+ (strlen(
path
) - strlen(
"proc-streams"
)),
"test"
);
23
24
char
*
args
[2];
25
args
[0] =
path
;
26
args
[1] =
NULL
;
27
28
/* ... */
29
30
options
.
stdio_count
= 3;
31
uv_stdio_container_t
child_stdio[3];
32
child_stdio[0].
flags
=
UV_IGNORE
;
33
child_stdio[1].
flags
=
UV_IGNORE
;
34
child_stdio[2].
flags
=
UV_INHERIT_FD
;
35
child_stdio[2].
data
.
fd
= 2;
36
options
.
stdio
= child_stdio;
37
38
options
.
exit_cb
=
on_exit
;
39
options
.
file
=
args
[0];
40
options
.
args
=
args
;
41
42
int
r
;
43
if
((
r
=
uv_spawn
(
loop
, &
child_req
, &
options
))) {
44
fprintf(stderr,
"%s\n"
,
uv_strerror
(
r
));
45
return
1;
46
}
47
48
return
uv_run
(
loop
,
UV_RUN_DEFAULT
);
49
}
NULL
#define NULL
Definition:
cris-opc.c:27
r
#define r
Definition:
crypto_rc6.c:12
path
static static fork const void static count static fd const char const char static newpath const char static path const char path
Definition:
sflib.h:35
req
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec req
Definition:
sflib.h:128
size
voidpf void uLong size
Definition:
ioapi.h:138
PRId64
#define PRId64
Definition:
macros.h:17
main
int main(int argc, const char **argv)
Definition:
main.c:340
int64_t
long int64_t
Definition:
sftypes.h:32
uv_handle_s
Definition:
uv.h:444
uv_loop_s
Definition:
uv.h:1780
uv_process_options_s
Definition:
uv.h:951
uv_process_options_s::file
const char * file
Definition:
uv.h:953
uv_process_options_s::stdio
uv_stdio_container_t * stdio
Definition:
uv.h:986
uv_process_options_s::args
char ** args
Definition:
uv.h:960
uv_process_options_s::stdio_count
int stdio_count
Definition:
uv.h:985
uv_process_options_s::exit_cb
uv_exit_cb exit_cb
Definition:
uv.h:952
uv_process_s
Definition:
uv.h:1048
uv_stdio_container_s
Definition:
uv.h:942
uv_stdio_container_s::fd
int fd
Definition:
uv.h:947
uv_stdio_container_s::flags
uv_stdio_flags flags
Definition:
uv.h:943
uv_stdio_container_s::data
union uv_stdio_container_s::@397 data
options
uv_process_options_t options
Definition:
main.c:9
loop
uv_loop_t * loop
Definition:
main.c:7
child_req
uv_process_t child_req
Definition:
main.c:8
on_exit
void on_exit(uv_process_t *req, int64_t exit_status, int term_signal)
Definition:
main.c:11
args
struct Arg * args
Definition:
mipsasm.c:18
exit_status
static enum exit_status_type exit_status
Exit status to use. This can be changed with set_exit_status().
Definition:
main.c:17
uv.h
uv_exepath
UV_EXTERN int uv_exepath(char *buffer, size_t *size)
Definition:
aix-common.c:60
UV_INHERIT_FD
@ UV_INHERIT_FD
Definition:
uv.h:924
UV_IGNORE
@ UV_IGNORE
Definition:
uv.h:922
UV_RUN_DEFAULT
@ UV_RUN_DEFAULT
Definition:
uv.h:255
uv_spawn
UV_EXTERN int uv_spawn(uv_loop_t *loop, uv_process_t *handle, const uv_process_options_t *options)
Definition:
process.c:408
uv_run
UV_EXTERN int uv_run(uv_loop_t *, uv_run_mode mode)
Definition:
core.c:365
uv_close
UV_EXTERN void uv_close(uv_handle_t *handle, uv_close_cb close_cb)
Definition:
core.c:108
uv_strerror
UV_EXTERN const char * uv_strerror(int err)
Definition:
uv-common.c:212
uv_default_loop
UV_EXTERN uv_loop_t * uv_default_loop(void)
Definition:
uv-common.c:763
subprojects
libuv-v1.40.0
docs
code
proc-streams
main.c
Generated by
1.9.1