aboutsummaryrefslogtreecommitdiff
path: root/client.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-12-21 18:56:37 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-12-21 18:56:37 +0000
commit277735db65799aada06a5013fe747a48dfa6040b (patch)
tree1a6af5d8b66320af5a752a1ef947b7b1ee5f7673 /client.c
parentMerge branch 'launch-new-instance' (diff)
client/server: client sends its CWD to server
Diffstat (limited to 'client.c')
-rw-r--r--client.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/client.c b/client.c
index d581429b..bbb8ea8c 100644
--- a/client.c
+++ b/client.c
@@ -127,10 +127,15 @@ main(int argc, char *const *argv)
}
}
+ char cwd[4096];
+ getcwd(cwd, sizeof(cwd));
+ const uint16_t cwd_len = strlen(cwd) + 1;
+
const uint16_t term_len = strlen(term) + 1;
uint32_t total_len = 0;
/* Calculate total length */
+ total_len += sizeof(cwd_len) + cwd_len;
total_len += sizeof(term_len) + term_len;
total_len += sizeof(argc);
@@ -147,6 +152,13 @@ main(int argc, char *const *argv)
goto err;
}
+ if (send(fd, &cwd_len, sizeof(cwd_len), 0) != sizeof(cwd_len) ||
+ send(fd, cwd, cwd_len, 0) != cwd_len)
+ {
+ LOG_ERRNO("failed to send CWD to server");
+ goto err;
+ }
+
if (send(fd, &term_len, sizeof(term_len), 0) != sizeof(term_len) ||
send(fd, term, term_len, 0) != term_len)
{