parent
e36590cda7
commit
1e5e19bc23
@ -149,7 +149,13 @@ int init_unix_socket(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
sa.sun_family = AF_UNIX;
|
sa.sun_family = AF_UNIX;
|
||||||
|
|
||||||
|
if (_native_unix_socket_path != NULL) {
|
||||||
|
snprintf(sa.sun_path, sizeof(sa.sun_path), "%s", _native_unix_socket_path);
|
||||||
|
}
|
||||||
|
else {
|
||||||
snprintf(sa.sun_path, sizeof(sa.sun_path), "/tmp/riot.tty.%d", _native_pid);
|
snprintf(sa.sun_path, sizeof(sa.sun_path), "/tmp/riot.tty.%d", _native_pid);
|
||||||
|
}
|
||||||
unlink(sa.sun_path); /* remove stale socket */
|
unlink(sa.sun_path); /* remove stale socket */
|
||||||
if (bind(s, (struct sockaddr *)&sa, SUN_LEN(&sa)) == -1) {
|
if (bind(s, (struct sockaddr *)&sa, SUN_LEN(&sa)) == -1) {
|
||||||
err(EXIT_FAILURE, "init_unix_socket: bind");
|
err(EXIT_FAILURE, "init_unix_socket: bind");
|
||||||
|
|||||||
@ -79,6 +79,7 @@ extern ucontext_t *_native_cur_ctx, *_native_isr_ctx;
|
|||||||
extern const char *_progname;
|
extern const char *_progname;
|
||||||
extern char **_native_argv;
|
extern char **_native_argv;
|
||||||
extern pid_t _native_pid;
|
extern pid_t _native_pid;
|
||||||
|
extern const char *_native_unix_socket_path;
|
||||||
|
|
||||||
#ifdef MODULE_UART0
|
#ifdef MODULE_UART0
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
|
|||||||
@ -44,6 +44,7 @@ int _native_null_out_file;
|
|||||||
const char *_progname;
|
const char *_progname;
|
||||||
char **_native_argv;
|
char **_native_argv;
|
||||||
pid_t _native_pid;
|
pid_t _native_pid;
|
||||||
|
const char *_native_unix_socket_path = NULL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* initialize _native_null_in_pipe to allow for reading from stdin
|
* initialize _native_null_in_pipe to allow for reading from stdin
|
||||||
@ -160,7 +161,7 @@ void usage_exit(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODULE_UART0
|
#ifdef MODULE_UART0
|
||||||
real_printf(" [-t <port>|-u]");
|
real_printf(" [-t <port>|-u [path]]");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
real_printf(" [-d] [-e|-E] [-o]\n");
|
real_printf(" [-d] [-e|-E] [-o]\n");
|
||||||
@ -177,6 +178,7 @@ void usage_exit(void)
|
|||||||
#ifdef MODULE_UART0
|
#ifdef MODULE_UART0
|
||||||
real_printf("\
|
real_printf("\
|
||||||
-u redirect stdio to UNIX socket\n\
|
-u redirect stdio to UNIX socket\n\
|
||||||
|
if no path is given /tmp/riot.tty.PID is used\n\
|
||||||
-t redirect stdio to TCP socket\n");
|
-t redirect stdio to TCP socket\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -272,6 +274,11 @@ __attribute__((constructor)) static void startup(int argc, char **argv)
|
|||||||
if (strcmp(stderrtype, "stdio") == 0) {
|
if (strcmp(stderrtype, "stdio") == 0) {
|
||||||
stderrtype = "null";
|
stderrtype = "null";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* parse optional path */
|
||||||
|
if ((argp + 1 < argc) && (argv[argp + 1][0] != '-')) {
|
||||||
|
_native_unix_socket_path = argv[++argp];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else {
|
else {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user