diff mbox

open_init_pty: Do not error on EINTR

Message ID 1467526822-19491-1-git-send-email-jason@perfinion.com (mailing list archive)
State Not Applicable
Headers show

Commit Message

Jason Zaman July 3, 2016, 6:20 a.m. UTC
There is a signal handler so that the select returns EINTR when the
child exits. EINTR is used to then clean up and flush the remaining
buffers. It should not error.

Signed-off-by: Jason Zaman <jason@perfinion.com>
---
 policycoreutils/run_init/open_init_pty.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Stephen Smalley July 12, 2016, 7:38 p.m. UTC | #1
On 07/03/2016 02:20 AM, Jason Zaman wrote:
> There is a signal handler so that the select returns EINTR when the
> child exits. EINTR is used to then clean up and flush the remaining
> buffers. It should not error.
> 
> Signed-off-by: Jason Zaman <jason@perfinion.com>

Thanks, applied.

> ---
>  policycoreutils/run_init/open_init_pty.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/policycoreutils/run_init/open_init_pty.c b/policycoreutils/run_init/open_init_pty.c
> index 37805bf..6e25ea3 100644
> --- a/policycoreutils/run_init/open_init_pty.c
> +++ b/policycoreutils/run_init/open_init_pty.c
> @@ -327,8 +327,9 @@ int main(int argc, char *argv[])
>  			break;
>  		}
>  
> +		errno = 0;
>  		int select_rc = select(pty_master + 1, &readfds, &writefds, NULL, NULL);
> -		if (select_rc < 0) {
> +		if (select_rc < 0 && errno != EINTR) {
>  			perror("select()");
>  			exit(EX_IOERR);
>  		}
>
diff mbox

Patch

diff --git a/policycoreutils/run_init/open_init_pty.c b/policycoreutils/run_init/open_init_pty.c
index 37805bf..6e25ea3 100644
--- a/policycoreutils/run_init/open_init_pty.c
+++ b/policycoreutils/run_init/open_init_pty.c
@@ -327,8 +327,9 @@  int main(int argc, char *argv[])
 			break;
 		}
 
+		errno = 0;
 		int select_rc = select(pty_master + 1, &readfds, &writefds, NULL, NULL);
-		if (select_rc < 0) {
+		if (select_rc < 0 && errno != EINTR) {
 			perror("select()");
 			exit(EX_IOERR);
 		}