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

Test to exercise signal delivery during a blocked pipe send. #1046

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

rwatson
Copy link
Member

@rwatson rwatson commented Jul 14, 2021

Test to trigger #1045 without the more complex IPC context that the original test required for other purposes.

Comment on lines +65 to +67
{

}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{
}
{
}

CHERIBSDTEST_CHECK_SYSCALL(alarm(1));
len = write(fds[0], buffer, sizeof(buffer));
if (len < 0 && errno != EINTR)
cheribsdtest_failure_err("write");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really a successful test if you write the entire buffer without getting interrupted? If you want to ensure that the write was interrupted, then I think what you want to do instead might be something like:

static volatile sig_atomic_t alarm_fired;

static void
sigalrm_handler(...)
{
    alarm_fired = 1;
}

CHERIBSDTEST(...)
{
   ...
   len = write(fds[0], buffer, sizeof(buffer));
   if (len == -1 && errno != EINTR)
       cheribsdtest_failure_err("write");
   /* we probably have some sort of wrapper for this */
   if (alarm_fired == 0)
       cheribsdtest_failure("failed to interrupt write");

Even this is somewhat racy as in theory the handler could fire before or after the write(), but those races are probably rare enough to ignore.

@paulmetzger paulmetzger deleted the cheribsd_pipe_sleep_signal_test branch July 11, 2022 10:36
@jrtc27 jrtc27 restored the cheribsd_pipe_sleep_signal_test branch July 11, 2022 14:54
@jrtc27 jrtc27 reopened this Jul 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants