/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 2023 Andreas Bock <[email protected]>4* Copyright (c) 2023 Mark Johnston <[email protected]>5*6* Redistribution and use in source and binary forms, with or without7* modification, are permitted provided that the following conditions are8* met:9* 1. Redistributions of source code must retain the above copyright10* notice, this list of conditions and the following disclaimer.11* 2. Redistributions in binary form must reproduce the above copyright12* notice, this list of conditions and the following disclaimer in13* the documentation and/or other materials provided with the distribution.14*15* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND16* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE17* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE18* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE19* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL20* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS21* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)22* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT23* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY24* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF25* SUCH DAMAGE.26*/2728#include <sys/event.h>29#include <sys/wait.h>3031#include <err.h>32#include <signal.h>33#include <unistd.h>3435#include <atf-c.h>3637/*38* A regression test for bugzilla 275286.39*/40ATF_TC_WITHOUT_HEAD(shared_table_filt_sig);41ATF_TC_BODY(shared_table_filt_sig, tc)42{43struct sigaction sa;44pid_t pid;45int error, status;4647sa.sa_handler = SIG_IGN;48sigemptyset(&sa.sa_mask);49sa.sa_flags = 0;50error = sigaction(SIGINT, &sa, NULL);51ATF_REQUIRE(error == 0);5253pid = rfork(RFPROC);54ATF_REQUIRE(pid != -1);55if (pid == 0) {56struct kevent ev;57int kq;5859kq = kqueue();60if (kq < 0)61err(1, "kqueue");62EV_SET(&ev, SIGINT, EVFILT_SIGNAL, EV_ADD | EV_ENABLE, 0, 0,63NULL);64if (kevent(kq, &ev, 1, NULL, 0, NULL) < 0)65err(2, "kevent");66if (kevent(kq, NULL, 0, &ev, 1, NULL) < 0)67err(3, "kevent");68_exit(0);69}7071/* Wait for the child to block in kevent(). */72usleep(100000);7374error = kill(pid, SIGINT);75ATF_REQUIRE(error == 0);7677error = waitpid(pid, &status, 0);78ATF_REQUIRE(error != -1);79ATF_REQUIRE(WIFEXITED(status));80ATF_REQUIRE_EQ(WEXITSTATUS(status), 0);81}8283ATF_TP_ADD_TCS(tp)84{85ATF_TP_ADD_TC(tp, shared_table_filt_sig);8687return (atf_no_error());88}899091