Skip to content

Commit 0f298df

Browse files
author
Razvan Becheriu
committed
[#3351] use execve to silence valgrind on child exit
1 parent 924b256 commit 0f298df

File tree

5 files changed

+10
-2
lines changed

5 files changed

+10
-2
lines changed

configure.ac

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1682,6 +1682,8 @@ AC_CONFIG_FILES([src/lib/process/cfgrpt/Makefile])
16821682
AC_CONFIG_FILES([src/lib/process/cfgrpt/tests/Makefile])
16831683
AC_CONFIG_FILES([src/lib/process/tests/Makefile])
16841684
AC_CONFIG_FILES([src/lib/process/testutils/Makefile])
1685+
AC_CONFIG_FILES([src/lib/process/tests/process_test.sh],
1686+
[chmod +x src/lib/process/tests/process_test.sh])
16851687
AC_CONFIG_FILES([src/lib/stats/Makefile])
16861688
AC_CONFIG_FILES([src/lib/stats/tests/Makefile])
16871689
AC_CONFIG_FILES([src/lib/stats/testutils/Makefile])

src/lib/process/tests/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/libprocess_unittests
2+
/process_test.sh

src/lib/process/tests/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ dhcp_data_dir = @runstatedir@/@PACKAGE@
33
AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
44
AM_CPPFLAGS += $(BOOST_INCLUDES)
55
AM_CPPFLAGS += -DTEST_DATA_BUILDDIR=\"$(abs_top_builddir)/src/lib/process/tests\"
6+
AM_CPPFLAGS += -DTEST_SCRIPT_SH=\"$(abs_top_builddir)/src/lib/process/tests/process_test.sh\"
67
AM_CPPFLAGS += -DDATA_DIR="\"$(dhcp_data_dir)\""
78
AM_CPPFLAGS += -DINSTALL_PROG=\"$(abs_top_srcdir)/install-sh\"
89

src/lib/process/tests/daemon_unittest.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,11 @@ TEST_F(DaemonTest, createPIDFileOverwrite) {
221221
ASSERT_GE(pid, 0);
222222

223223
if (pid == 0) {
224-
// This is the child, die right away. Tragic, no?
225-
_exit (0);
224+
char name[] = TEST_SCRIPT_SH;
225+
char* argv[] = { name, 0 };
226+
char* envp[] = { 0 };
227+
execve(name, argv, envp);
228+
_exit(0);
226229
}
227230

228231
// Back in the parent test, we need to wait for the child to die
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#!/bin/sh

0 commit comments

Comments
 (0)