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

Lack of sending SIGPIPE signal #733

Open
adamdebek opened this issue May 19, 2023 · 0 comments · May be fixed by phoenix-rtos/phoenix-rtos-kernel#514
Open

Lack of sending SIGPIPE signal #733

adamdebek opened this issue May 19, 2023 · 0 comments · May be fixed by phoenix-rtos/phoenix-rtos-kernel#514

Comments

@adamdebek
Copy link
Contributor

adamdebek commented May 19, 2023

From open group write() doc:

image
Code to reproduction:

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

pid_t pid;
int pipefd[2];

void handler(int signum)
{
        printf("In handler\n");
}


int main(void)
{
	pipe(pipefd);
	pid = fork();
	if (pid == 0){
		exit(0);
	}
	sleep(1);

	struct sigaction sa;
	sa.sa_handler = handler;
	sigemptyset(&sa.sa_mask);
	sa.sa_flags = 0;
	sigaction(SIGPIPE, &sa, NULL);

	close(pipefd[0]);
	int ret = write(pipefd[1], "aa", 2);
	printf("errno: %d\n", errno); //32 = EPIPE
	printf("ret: %d\n", ret);

	return 0;
}

Output:
image

Parent process should get SIGPIPE and invoke handler. Probably same fix in read().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant