mirror of https://github.com/martanne/abduco
If stdin is not a terminal pass-through its data to the session
This allows to send commands to a running session:
echo cowsay hi | abduco -a session
See #8 for initial discussion of the feature.
This commit is contained in:
parent
5a46912d62
commit
c901f2bbb8
3
abduco.1
3
abduco.1
|
|
@ -76,6 +76,9 @@ If for some reason the
|
||||||
domain socket representing a session is deleted, sending
|
domain socket representing a session is deleted, sending
|
||||||
.BR SIGUSR1
|
.BR SIGUSR1
|
||||||
to the server process will recreate it.
|
to the server process will recreate it.
|
||||||
|
|
||||||
|
If standard input does not refer to a terminal, its content is passed
|
||||||
|
through to the underlying session.
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
If no command line arguments are given all currently active sessions are
|
If no command line arguments are given all currently active sessions are
|
||||||
printed sorted by their respective creation date. Lines starting with an
|
printed sorted by their respective creation date. Lines starting with an
|
||||||
|
|
|
||||||
11
abduco.c
11
abduco.c
|
|
@ -120,7 +120,7 @@ typedef struct {
|
||||||
static Server server = { .running = true, .exit_status = -1, .host = "@localhost" };
|
static Server server = { .running = true, .exit_status = -1, .host = "@localhost" };
|
||||||
static Client client;
|
static Client client;
|
||||||
static struct termios orig_term, cur_term;
|
static struct termios orig_term, cur_term;
|
||||||
static bool has_term, alternate_buffer, quiet;
|
static bool has_term, alternate_buffer, quiet, passthrough;
|
||||||
|
|
||||||
static struct sockaddr_un sockaddr = {
|
static struct sockaddr_un sockaddr = {
|
||||||
.sun_family = AF_UNIX,
|
.sun_family = AF_UNIX,
|
||||||
|
|
@ -588,6 +588,8 @@ int main(int argc, char *argv[]) {
|
||||||
server.name = basename(argv[0]);
|
server.name = basename(argv[0]);
|
||||||
gethostname(server.host+1, sizeof(server.host) - 1);
|
gethostname(server.host+1, sizeof(server.host) - 1);
|
||||||
|
|
||||||
|
passthrough = !isatty(STDIN_FILENO);
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "aAclne:fqrv")) != -1) {
|
while ((opt = getopt(argc, argv, "aAclne:fqrv")) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'a':
|
case 'a':
|
||||||
|
|
@ -623,6 +625,11 @@ int main(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (passthrough) {
|
||||||
|
quiet = true;
|
||||||
|
client.flags |= CLIENT_LOWPRIORITY;
|
||||||
|
}
|
||||||
|
|
||||||
/* collect the session name if trailing args */
|
/* collect the session name if trailing args */
|
||||||
if (optind < argc)
|
if (optind < argc)
|
||||||
server.session_name = argv[optind];
|
server.session_name = argv[optind];
|
||||||
|
|
@ -638,7 +645,7 @@ int main(int argc, char *argv[]) {
|
||||||
if (!action || !server.session_name)
|
if (!action || !server.session_name)
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
if (tcgetattr(STDIN_FILENO, &orig_term) != -1) {
|
if (!passthrough && tcgetattr(STDIN_FILENO, &orig_term) != -1) {
|
||||||
server.term = orig_term;
|
server.term = orig_term;
|
||||||
has_term = true;
|
has_term = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
3
client.c
3
client.c
|
|
@ -100,7 +100,8 @@ static int client_mainloop(void) {
|
||||||
if (client_recv_packet(&pkt)) {
|
if (client_recv_packet(&pkt)) {
|
||||||
switch (pkt.type) {
|
switch (pkt.type) {
|
||||||
case MSG_CONTENT:
|
case MSG_CONTENT:
|
||||||
write_all(STDOUT_FILENO, pkt.u.msg, pkt.len);
|
if (!passthrough)
|
||||||
|
write_all(STDOUT_FILENO, pkt.u.msg, pkt.len);
|
||||||
break;
|
break;
|
||||||
case MSG_RESIZE:
|
case MSG_RESIZE:
|
||||||
client.need_resize = true;
|
client.need_resize = true;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue