Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
0478ee04
Commit
0478ee04
authored
Sep 01, 2013
by
Matt Connolly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding test showing failure to close socket/context in forked child
parent
8ef7fbb4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
80 additions
and
2 deletions
+80
-2
.gitignore
.gitignore
+1
-0
configure.ac
configure.ac
+1
-1
Makefile.am
tests/Makefile.am
+3
-1
test_fork.cpp
tests/test_fork.cpp
+75
-0
No files found.
.gitignore
View file @
0478ee04
...
...
@@ -60,6 +60,7 @@ tests/test_spec_req
tests/test_spec_router
tests/test_req_request_ids
tests/test_req_strict
tests/test_fork
src/platform.hpp*
src/stamp-h1
perf/local_lat
...
...
configure.ac
View file @
0478ee04
...
...
@@ -388,7 +388,7 @@ AM_CONDITIONAL(ON_ANDROID, test "x$libzmq_on_android" = "xyes")
# Checks for library functions.
AC_TYPE_SIGNAL
AC_CHECK_FUNCS(perror gettimeofday clock_gettime memset socket getifaddrs freeifaddrs)
AC_CHECK_FUNCS(perror gettimeofday clock_gettime memset socket getifaddrs freeifaddrs
fork
)
AC_CHECK_HEADERS([alloca.h])
LIBZMQ_CHECK_SOCK_CLOEXEC([AC_DEFINE(
[ZMQ_HAVE_SOCK_CLOEXEC],
...
...
tests/Makefile.am
View file @
0478ee04
...
...
@@ -38,7 +38,8 @@ if !ON_MINGW
noinst_PROGRAMS
+=
test_shutdown_stress
\
test_pair_ipc
\
test_reqrep_ipc
\
test_timeo
test_timeo
\
test_fork
endif
test_pair_inproc_SOURCES
=
test_pair_inproc.cpp testutil.hpp
...
...
@@ -76,6 +77,7 @@ test_shutdown_stress_SOURCES = test_shutdown_stress.cpp
test_pair_ipc_SOURCES
=
test_pair_ipc.cpp testutil.hpp
test_reqrep_ipc_SOURCES
=
test_reqrep_ipc.cpp testutil.hpp
test_timeo_SOURCES
=
test_timeo.cpp
test_fork_SOURCES
=
test_fork.cpp
endif
# Deprecated test cases
...
...
tests/test_fork.cpp
0 → 100644
View file @
0478ee04
/*
Copyright (c) 2007-2013 Contributors as noted in the AUTHORS file
This file is part of 0MQ.
0MQ is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
0MQ is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "../include/zmq.h"
#include "../include/zmq_utils.h"
#include <stdio.h>
#include <string.h>
#include "testutil.hpp"
#include <unistd.h>
#include <signal.h>
const
char
*
address
=
"tcp://127.0.0.1:6571"
;
void
my_handler
(
int
,
siginfo_t
*
info
,
void
*
uap
);
volatile
int
child_exited
=
0
;
volatile
int
child_exit_code
=
0
;
int
main
(
void
)
{
int
rc
;
setup_test_environment
();
printf
(
"parent: process id = %d
\n
"
,
(
int
)
getpid
());
void
*
ctx
=
zmq_ctx_new
();
assert
(
ctx
);
void
*
sock
=
zmq_socket
(
ctx
,
ZMQ_PULL
);
assert
(
sock
);
rc
=
zmq_connect
(
sock
,
address
);
assert
(
rc
==
0
);
// wait for io threads to be running
usleep
(
100000
);
int
pid
=
fork
();
if
(
pid
==
0
)
{
sleep
(
1
);
printf
(
"child: process id = %d
\n
"
,
(
int
)
getpid
());
printf
(
"child: terminating inherited context...
\n
"
);
// close the socket, or the context gets stuck indefinitely
zmq_close
(
sock
);
zmq_term
(
ctx
);
printf
(
"child done
\n
"
);
exit
(
0
);
}
else
{
int
child_status
;
while
(
true
)
{
rc
=
waitpid
(
pid
,
&
child_status
,
0
);
if
(
rc
==
-
1
&&
errno
==
EINTR
)
continue
;
printf
(
"parent: child exit code = %d, rc = %d, errno = %d
\n
"
,
WEXITSTATUS
(
child_status
),
rc
,
errno
);
assert
(
WEXITSTATUS
(
child_status
)
==
0
);
break
;
}
printf
(
"parent done.
\n
"
);
exit
(
0
);
}
return
0
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment