aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/outcome
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-11-16 20:57:29 +0900
committerOphestra <cat@gensokyo.uk>2025-11-16 20:57:29 +0900
commitb73a789dfe2b7361d9fce7d6755d14e44f6d9d57 (patch)
tree59e771315c64d90ff6c3f11d371b2fdbf7347ee1 /internal/outcome
parent38b5ff0cec266c7c5e423b68e8626f4a4a63d3ee (diff)
.clang-format: increase indent width
This significantly increases readability. This patch is pretty big so it is being done after mostly everything has settled. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/outcome')
-rw-r--r--internal/outcome/shim-signal.c72
-rw-r--r--internal/outcome/shim-signal.h8
2 files changed, 40 insertions, 40 deletions
diff --git a/internal/outcome/shim-signal.c b/internal/outcome/shim-signal.c
index 0e04abb4..f02c0df1 100644
--- a/internal/outcome/shim-signal.c
+++ b/internal/outcome/shim-signal.c
@@ -10,53 +10,53 @@ static int hakurei_shim_fd = -1;
/* see shim.go for handling of the message */
static inline ssize_t hakurei_shim_write(hakurei_shim_msg msg) {
- int savedErrno = errno;
- unsigned char buf = (unsigned char)msg;
- ssize_t ret = write(hakurei_shim_fd, &buf, 1);
- if (ret == -1 && errno != EAGAIN)
- exit(EXIT_FAILURE);
- errno = savedErrno;
- return ret;
+ int savedErrno = errno;
+ unsigned char buf = (unsigned char)msg;
+ ssize_t ret = write(hakurei_shim_fd, &buf, 1);
+ if (ret == -1 && errno != EAGAIN)
+ exit(EXIT_FAILURE);
+ errno = savedErrno;
+ return ret;
}
static void hakurei_shim_sigaction(int sig, siginfo_t *si, void *ucontext) {
- if (sig != SIGCONT || si == NULL) {
- hakurei_shim_write(HAKUREI_SHIM_INVALID);
- return;
- }
+ if (sig != SIGCONT || si == NULL) {
+ hakurei_shim_write(HAKUREI_SHIM_INVALID);
+ return;
+ }
- if (si->si_pid == hakurei_shim_param_ppid) {
- hakurei_shim_write(HAKUREI_SHIM_EXIT_REQUESTED);
- return;
- }
+ if (si->si_pid == hakurei_shim_param_ppid) {
+ hakurei_shim_write(HAKUREI_SHIM_EXIT_REQUESTED);
+ return;
+ }
- hakurei_shim_write(HAKUREI_SHIM_BAD_PID);
+ hakurei_shim_write(HAKUREI_SHIM_BAD_PID);
- if (getppid() != hakurei_shim_param_ppid)
- hakurei_shim_write(HAKUREI_SHIM_ORPHAN);
+ if (getppid() != hakurei_shim_param_ppid)
+ hakurei_shim_write(HAKUREI_SHIM_ORPHAN);
}
void hakurei_shim_setup_cont_signal(pid_t ppid, int fd) {
- if (hakurei_shim_param_ppid != -1 || hakurei_shim_fd != -1)
- *(volatile int *)NULL = 0; /* unreachable */
+ if (hakurei_shim_param_ppid != -1 || hakurei_shim_fd != -1)
+ *(volatile int *)NULL = 0; /* unreachable */
- struct sigaction new_action = {0}, old_action = {0};
- if (sigaction(SIGCONT, NULL, &old_action) != 0)
- return;
- if (old_action.sa_handler != SIG_DFL) {
- errno = ENOTRECOVERABLE;
- return;
- }
+ struct sigaction new_action = {0}, old_action = {0};
+ if (sigaction(SIGCONT, NULL, &old_action) != 0)
+ return;
+ if (old_action.sa_handler != SIG_DFL) {
+ errno = ENOTRECOVERABLE;
+ return;
+ }
- new_action.sa_sigaction = hakurei_shim_sigaction;
- if (sigemptyset(&new_action.sa_mask) != 0)
- return;
- new_action.sa_flags = SA_ONSTACK | SA_SIGINFO;
+ new_action.sa_sigaction = hakurei_shim_sigaction;
+ if (sigemptyset(&new_action.sa_mask) != 0)
+ return;
+ new_action.sa_flags = SA_ONSTACK | SA_SIGINFO;
- if (sigaction(SIGCONT, &new_action, NULL) != 0)
- return;
+ if (sigaction(SIGCONT, &new_action, NULL) != 0)
+ return;
- errno = 0;
- hakurei_shim_param_ppid = ppid;
- hakurei_shim_fd = fd;
+ errno = 0;
+ hakurei_shim_param_ppid = ppid;
+ hakurei_shim_fd = fd;
}
diff --git a/internal/outcome/shim-signal.h b/internal/outcome/shim-signal.h
index b0229a91..f396a915 100644
--- a/internal/outcome/shim-signal.h
+++ b/internal/outcome/shim-signal.h
@@ -2,10 +2,10 @@
/* see shim.go for documentation */
typedef enum {
- HAKUREI_SHIM_EXIT_REQUESTED,
- HAKUREI_SHIM_ORPHAN,
- HAKUREI_SHIM_INVALID,
- HAKUREI_SHIM_BAD_PID,
+ HAKUREI_SHIM_EXIT_REQUESTED,
+ HAKUREI_SHIM_ORPHAN,
+ HAKUREI_SHIM_INVALID,
+ HAKUREI_SHIM_BAD_PID,
} hakurei_shim_msg;
void hakurei_shim_setup_cont_signal(pid_t ppid, int fd);