Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sigaction() not handling flags and mask error #1234

Open
adamdebek opened this issue Nov 21, 2024 · 0 comments
Open

sigaction() not handling flags and mask error #1234

adamdebek opened this issue Nov 21, 2024 · 0 comments
Labels
bug Something isn't working libphoenix

Comments

@adamdebek
Copy link
Contributor

sigaction() do not handle flags, it is marked as TODO in code

mask error reproduction (ia32-generic-qemu):

#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
#include <unistd.h>


void handler(int sig) {
    sigset_t handler_set;

    if (sigprocmask(SIG_SETMASK, NULL, &handler_set) < 0) {
        fprintf(stderr, "sigprocmask error\n");
        return;
    }

    if (sigismember(&handler_set, SIGCHLD) != 1) {
        fprintf(stderr, "no caught signal in mask\n");
    }

    if (sigismember(&handler_set, SIGHUP) != 1) {
        fprintf(stderr, "no currently blocked signal in mask\n");
    }

    if (sigismember(&handler_set, SIGPIPE) != 1) {
        fprintf(stderr, "no specified in sigaction signal in mask]n");
    }
}


int main(void) {
    sigset_t set;
    struct sigaction sa;

    sigemptyset(&set);
    sigaddset(&set, SIGHUP);

    if (sigprocmask(SIG_SETMASK, &set, NULL) < 0) {
        perror("sigprocmask");
        exit(EXIT_FAILURE);
    }

    sa.sa_handler = handler;
    sa.sa_flags = 0;
    sigaddset(&set, SIGPIPE);
    sa.sa_mask = set;

    if (sigaction(SIGCHLD, &sa, NULL) < 0) {
        perror("sigaction");
        exit(EXIT_FAILURE);
    }

    if (kill(getpid(), SIGCHLD) < 0) {
        perror("kill");
        exit(EXIT_FAILURE);
    }

    return 0;
}
@adamdebek adamdebek added bug Something isn't working libphoenix labels Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working libphoenix
Projects
None yet
Development

No branches or pull requests

1 participant