[1/5] socket-tcp: ignore SIGPIPE

Submitted by Andrei Vagin on Nov. 27, 2018, 5:45 p.m.

Details

Message ID 20181127174545.3872-2-avagin@gmail.com
State Accepted
Series "travis: switch to the Ubuntu Xenial"
Headers show

Commit Message

Andrei Vagin Nov. 27, 2018, 5:45 p.m.
In this tests, we are trying to read from closed sockets.

Signed-off-by: Andrei Vagin <avagin@gmail.com>
---
 test/zdtm/static/socket-tcp-closed.c  | 2 ++
 test/zdtm/static/socket-tcp-reseted.c | 2 ++
 2 files changed, 4 insertions(+)

Patch hide | download patch | download mbox

diff --git a/test/zdtm/static/socket-tcp-closed.c b/test/zdtm/static/socket-tcp-closed.c
index 0447e95b2..a51f9b96d 100644
--- a/test/zdtm/static/socket-tcp-closed.c
+++ b/test/zdtm/static/socket-tcp-closed.c
@@ -23,6 +23,7 @@  const char *test_author = "Andrey Vagin <avagin@openvz.org";
 #include <signal.h>
 #include <netinet/tcp.h>
 #include <arpa/inet.h>
+#include <signal.h>
 
 static int port = 8880;
 
@@ -43,6 +44,7 @@  int main(int argc, char **argv)
 #endif
 
 	test_init(argc, argv);
+	signal(SIGPIPE, SIG_IGN);
 
 	sk = socket(ZDTM_FAMILY, SOCK_STREAM, 0);
 	if (sk < 0) {
diff --git a/test/zdtm/static/socket-tcp-reseted.c b/test/zdtm/static/socket-tcp-reseted.c
index ce52e1148..07ad36009 100644
--- a/test/zdtm/static/socket-tcp-reseted.c
+++ b/test/zdtm/static/socket-tcp-reseted.c
@@ -5,6 +5,7 @@ 
 #include <arpa/inet.h>  /* for sockaddr_in and inet_ntoa() */
 #include <stdlib.h>
 #include <sys/wait.h>
+#include <signal.h>
 
 #ifdef ZDTM_IPV4V6
 #define ZDTM_FAMILY AF_INET
@@ -38,6 +39,7 @@  int main(int argc, char **argv)
 	char cmd[4096], buf[10];
 
 	test_init(argc, argv);
+	signal(SIGPIPE, SIG_IGN);
 
 	if ((fd_s = tcp_init_server(ZDTM_SRV_FAMILY, &port)) < 0) {
 		pr_err("initializing server failed\n");

Comments

Mike Rapoport Nov. 28, 2018, 7:35 a.m.
On Tue, Nov 27, 2018 at 08:45:41PM +0300, Andrei Vagin wrote:
> In this tests, we are trying to read from closed sockets.

And? ;-)

A few more words would be really nice.
 
> Signed-off-by: Andrei Vagin <avagin@gmail.com>
> ---
>  test/zdtm/static/socket-tcp-closed.c  | 2 ++
>  test/zdtm/static/socket-tcp-reseted.c | 2 ++
>  2 files changed, 4 insertions(+)
> 
> diff --git a/test/zdtm/static/socket-tcp-closed.c b/test/zdtm/static/socket-tcp-closed.c
> index 0447e95b2..a51f9b96d 100644
> --- a/test/zdtm/static/socket-tcp-closed.c
> +++ b/test/zdtm/static/socket-tcp-closed.c
> @@ -23,6 +23,7 @@ const char *test_author = "Andrey Vagin <avagin@openvz.org";
>  #include <signal.h>
>  #include <netinet/tcp.h>
>  #include <arpa/inet.h>
> +#include <signal.h>
> 
>  static int port = 8880;
> 
> @@ -43,6 +44,7 @@ int main(int argc, char **argv)
>  #endif
> 
>  	test_init(argc, argv);
> +	signal(SIGPIPE, SIG_IGN);
> 
>  	sk = socket(ZDTM_FAMILY, SOCK_STREAM, 0);
>  	if (sk < 0) {
> diff --git a/test/zdtm/static/socket-tcp-reseted.c b/test/zdtm/static/socket-tcp-reseted.c
> index ce52e1148..07ad36009 100644
> --- a/test/zdtm/static/socket-tcp-reseted.c
> +++ b/test/zdtm/static/socket-tcp-reseted.c
> @@ -5,6 +5,7 @@
>  #include <arpa/inet.h>  /* for sockaddr_in and inet_ntoa() */
>  #include <stdlib.h>
>  #include <sys/wait.h>
> +#include <signal.h>
> 
>  #ifdef ZDTM_IPV4V6
>  #define ZDTM_FAMILY AF_INET
> @@ -38,6 +39,7 @@ int main(int argc, char **argv)
>  	char cmd[4096], buf[10];
> 
>  	test_init(argc, argv);
> +	signal(SIGPIPE, SIG_IGN);
> 
>  	if ((fd_s = tcp_init_server(ZDTM_SRV_FAMILY, &port)) < 0) {
>  		pr_err("initializing server failed\n");
> -- 
> 2.14.4
> 
> _______________________________________________
> CRIU mailing list
> CRIU@openvz.org
> https://lists.openvz.org/mailman/listinfo/criu
>
Andrei Vagin Nov. 29, 2018, 7:21 a.m.
On Wed, Nov 28, 2018 at 09:35:04AM +0200, Mike Rapoport wrote:
> On Tue, Nov 27, 2018 at 08:45:41PM +0300, Andrei Vagin wrote:
> > In this tests, we are trying to read from closed sockets.
> 
> And? ;-)
> 
> A few more words would be really nice.

Actually we are trying to write into a closed socket and the kernel
sends SIGPIPE in this case.

>  
> > Signed-off-by: Andrei Vagin <avagin@gmail.com>
> > ---
> >  test/zdtm/static/socket-tcp-closed.c  | 2 ++
> >  test/zdtm/static/socket-tcp-reseted.c | 2 ++
> >  2 files changed, 4 insertions(+)
> > 
> > diff --git a/test/zdtm/static/socket-tcp-closed.c b/test/zdtm/static/socket-tcp-closed.c
> > index 0447e95b2..a51f9b96d 100644
> > --- a/test/zdtm/static/socket-tcp-closed.c
> > +++ b/test/zdtm/static/socket-tcp-closed.c
> > @@ -23,6 +23,7 @@ const char *test_author = "Andrey Vagin <avagin@openvz.org";
> >  #include <signal.h>
> >  #include <netinet/tcp.h>
> >  #include <arpa/inet.h>
> > +#include <signal.h>
> > 
> >  static int port = 8880;
> > 
> > @@ -43,6 +44,7 @@ int main(int argc, char **argv)
> >  #endif
> > 
> >  	test_init(argc, argv);
> > +	signal(SIGPIPE, SIG_IGN);
> > 
> >  	sk = socket(ZDTM_FAMILY, SOCK_STREAM, 0);
> >  	if (sk < 0) {
> > diff --git a/test/zdtm/static/socket-tcp-reseted.c b/test/zdtm/static/socket-tcp-reseted.c
> > index ce52e1148..07ad36009 100644
> > --- a/test/zdtm/static/socket-tcp-reseted.c
> > +++ b/test/zdtm/static/socket-tcp-reseted.c
> > @@ -5,6 +5,7 @@
> >  #include <arpa/inet.h>  /* for sockaddr_in and inet_ntoa() */
> >  #include <stdlib.h>
> >  #include <sys/wait.h>
> > +#include <signal.h>
> > 
> >  #ifdef ZDTM_IPV4V6
> >  #define ZDTM_FAMILY AF_INET
> > @@ -38,6 +39,7 @@ int main(int argc, char **argv)
> >  	char cmd[4096], buf[10];
> > 
> >  	test_init(argc, argv);
> > +	signal(SIGPIPE, SIG_IGN);
> > 
> >  	if ((fd_s = tcp_init_server(ZDTM_SRV_FAMILY, &port)) < 0) {
> >  		pr_err("initializing server failed\n");
> > -- 
> > 2.14.4
> > 
> > _______________________________________________
> > CRIU mailing list
> > CRIU@openvz.org
> > https://lists.openvz.org/mailman/listinfo/criu
> > 
> 
> -- 
> Sincerely yours,
> Mike.
>
Mike Rapoport Nov. 29, 2018, 7:26 a.m.
On Wed, Nov 28, 2018 at 11:21:23PM -0800, Andrei Vagin wrote:
> On Wed, Nov 28, 2018 at 09:35:04AM +0200, Mike Rapoport wrote:
> > On Tue, Nov 27, 2018 at 08:45:41PM +0300, Andrei Vagin wrote:
> > > In this tests, we are trying to read from closed sockets.
> > 
> > And? ;-)
> > 
> > A few more words would be really nice.
> 
> Actually we are trying to write into a closed socket and the kernel
> sends SIGPIPE in this case.

"which is perfectly normal and should not fail the test"

;-)
 
> >  
> > > Signed-off-by: Andrei Vagin <avagin@gmail.com>
> > > ---
> > >  test/zdtm/static/socket-tcp-closed.c  | 2 ++
> > >  test/zdtm/static/socket-tcp-reseted.c | 2 ++
> > >  2 files changed, 4 insertions(+)
> > > 
> > > diff --git a/test/zdtm/static/socket-tcp-closed.c b/test/zdtm/static/socket-tcp-closed.c
> > > index 0447e95b2..a51f9b96d 100644
> > > --- a/test/zdtm/static/socket-tcp-closed.c
> > > +++ b/test/zdtm/static/socket-tcp-closed.c
> > > @@ -23,6 +23,7 @@ const char *test_author = "Andrey Vagin <avagin@openvz.org";
> > >  #include <signal.h>
> > >  #include <netinet/tcp.h>
> > >  #include <arpa/inet.h>
> > > +#include <signal.h>
> > > 
> > >  static int port = 8880;
> > > 
> > > @@ -43,6 +44,7 @@ int main(int argc, char **argv)
> > >  #endif
> > > 
> > >  	test_init(argc, argv);
> > > +	signal(SIGPIPE, SIG_IGN);
> > > 
> > >  	sk = socket(ZDTM_FAMILY, SOCK_STREAM, 0);
> > >  	if (sk < 0) {
> > > diff --git a/test/zdtm/static/socket-tcp-reseted.c b/test/zdtm/static/socket-tcp-reseted.c
> > > index ce52e1148..07ad36009 100644
> > > --- a/test/zdtm/static/socket-tcp-reseted.c
> > > +++ b/test/zdtm/static/socket-tcp-reseted.c
> > > @@ -5,6 +5,7 @@
> > >  #include <arpa/inet.h>  /* for sockaddr_in and inet_ntoa() */
> > >  #include <stdlib.h>
> > >  #include <sys/wait.h>
> > > +#include <signal.h>
> > > 
> > >  #ifdef ZDTM_IPV4V6
> > >  #define ZDTM_FAMILY AF_INET
> > > @@ -38,6 +39,7 @@ int main(int argc, char **argv)
> > >  	char cmd[4096], buf[10];
> > > 
> > >  	test_init(argc, argv);
> > > +	signal(SIGPIPE, SIG_IGN);
> > > 
> > >  	if ((fd_s = tcp_init_server(ZDTM_SRV_FAMILY, &port)) < 0) {
> > >  		pr_err("initializing server failed\n");
> > > -- 
> > > 2.14.4
> > > 
> > > _______________________________________________
> > > CRIU mailing list
> > > CRIU@openvz.org
> > > https://lists.openvz.org/mailman/listinfo/criu
> > > 
> > 
> > -- 
> > Sincerely yours,
> > Mike.
> > 
>