summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Cervin <albert@acervin.com>2025-11-21 21:52:14 +0100
committerAlbert Cervin <albert@acervin.com>2025-11-21 21:52:14 +0100
commitfa9277746ffc22b457d3c9cf96b91c5c73d5efc4 (patch)
tree4dc3a251580013efe2b91e428a295c5d8e8ed549
parent3940a20f62baf567cf31e1206adba050b477c9fa (diff)
downloaddged-fa9277746ffc22b457d3c9cf96b91c5c73d5efc4.tar.gz
dged-fa9277746ffc22b457d3c9cf96b91c5c73d5efc4.tar.xz
dged-fa9277746ffc22b457d3c9cf96b91c5c73d5efc4.zip
Rename the standard fds in process
To not collide with the <stdio.h> globals for stdin, stdout and stderr.
-rw-r--r--src/dged/lsp.c15
-rw-r--r--src/dged/process-posix.c12
-rw-r--r--src/dged/process.h6
3 files changed, 17 insertions, 16 deletions
diff --git a/src/dged/lsp.c b/src/dged/lsp.c
index dae0603..1fc59b4 100644
--- a/src/dged/lsp.c
+++ b/src/dged/lsp.c
@@ -233,7 +233,7 @@ uint32_t lsp_update(struct lsp *lsp, struct lsp_message *msgs,
uint8_t buf[1024];
if (reactor_poll_event(lsp->reactor, lsp->stderr_event)) {
ssize_t nb = 0;
- while ((nb = read(lsp->process->stderr, buf, 1024)) > 0) {
+ while ((nb = read(lsp->process->stderr_, buf, 1024)) > 0) {
buffer_set_readonly(lsp->stderr_buffer, false);
buffer_add(lsp->stderr_buffer, buffer_end(lsp->stderr_buffer), buf, nb);
buffer_set_readonly(lsp->stderr_buffer, true);
@@ -250,7 +250,8 @@ uint32_t lsp_update(struct lsp *lsp, struct lsp_message *msgs,
// write headers first
if (w->written < w->headers_len) {
to_write = w->headers_len - w->written;
- written = write(lsp->process->stdin, w->headers + w->written, to_write);
+ written =
+ write(lsp->process->stdin_, w->headers + w->written, to_write);
}
// did an error occur
@@ -267,7 +268,7 @@ uint32_t lsp_update(struct lsp *lsp, struct lsp_message *msgs,
if (w->written >= w->headers_len) {
to_write = w->payload.l + w->headers_len - w->written;
size_t offset = w->written - w->headers_len;
- written = write(lsp->process->stdin, w->payload.s + offset, to_write);
+ written = write(lsp->process->stdin_, w->payload.s + offset, to_write);
}
// did an error occur
@@ -355,16 +356,16 @@ int lsp_start_server(struct lsp *lsp) {
memcpy(lsp->process, &p, sizeof(struct process));
lsp->stdout_event = reactor_register_interest(
- lsp->reactor, lsp->process->stdout, ReadInterest);
+ lsp->reactor, lsp->process->stdout_, ReadInterest);
if (lsp->stdout_event == (uint32_t)-1) {
return -3;
}
lsp->stderr_event = reactor_register_interest(
- lsp->reactor, lsp->process->stderr, ReadInterest);
+ lsp->reactor, lsp->process->stderr_, ReadInterest);
- lsp->reader = bufread_create(lsp->process->stdout, 8192);
+ lsp->reader = bufread_create(lsp->process->stdout_, 8192);
return 0;
}
@@ -481,7 +482,7 @@ void lsp_send(struct lsp *lsp, struct lsp_message message) {
if (lsp->stdin_event == (uint32_t)-1) {
lsp->stdin_event = reactor_register_interest(
- lsp->reactor, lsp->process->stdin, WriteInterest);
+ lsp->reactor, lsp->process->stdin_, WriteInterest);
}
}
diff --git a/src/dged/process-posix.c b/src/dged/process-posix.c
index 7cfb29b..e5d5cf8 100644
--- a/src/dged/process-posix.c
+++ b/src/dged/process-posix.c
@@ -105,9 +105,9 @@ struct process_create_result process_create(char *const command[],
close(stdout_write);
close(stderr_write);
- result->stdin = stdin_write;
- result->stdout = stdout_read;
- result->stderr = stderr_read;
+ result->stdin_ = stdin_write;
+ result->stdout_ = stdout_read;
+ result->stderr_ = stderr_read;
result->id = (fd_t)pid;
result->impl = NULL;
}
@@ -118,9 +118,9 @@ struct process_create_result process_create(char *const command[],
}
void process_destroy(struct process *p) {
- close(p->stdin);
- close(p->stdout);
- close(p->stderr);
+ close(p->stdin_);
+ close(p->stdout_);
+ close(p->stderr_);
}
bool process_running(const struct process *p) {
diff --git a/src/dged/process.h b/src/dged/process.h
index cefec8c..179b9fa 100644
--- a/src/dged/process.h
+++ b/src/dged/process.h
@@ -13,9 +13,9 @@ typedef int fd_t;
struct platform_process;
struct process {
uint64_t id;
- fd_t stdin;
- fd_t stdout;
- fd_t stderr;
+ fd_t stdin_;
+ fd_t stdout_;
+ fd_t stderr_;
struct platform_process *impl;
};