Module Name: src
Committed By: pooka
Date: Mon Jul 26 14:53:52 UTC 2010
Modified Files:
src/tests/fs/common: puffs.c
Log Message:
catch "child died"
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/fs/common/puffs.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/fs/common/puffs.c
diff -u src/tests/fs/common/puffs.c:1.3 src/tests/fs/common/puffs.c:1.4
--- src/tests/fs/common/puffs.c:1.3 Mon Jul 19 16:09:08 2010
+++ src/tests/fs/common/puffs.c Mon Jul 26 14:53:52 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: puffs.c,v 1.3 2010/07/19 16:09:08 pooka Exp $ */
+/* $NetBSD: puffs.c,v 1.4 2010/07/26 14:53:52 pooka Exp $ */
/*
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -39,6 +39,7 @@
#include <pthread.h>
#include <puffs.h>
#include <puffsdump.h>
+#include <signal.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
@@ -215,6 +216,13 @@
pthread_detach(pt);
}
+static void
+childfail(int sign)
+{
+
+ atf_tc_fail("child died"); /* almost signal-safe */
+}
+
/* XXX: we don't support size */
int
puffs_fstest_newfs(const atf_tc_t *tc, void **argp,
@@ -222,7 +230,7 @@
{
struct puffstestargs *args;
char dtfs_path[MAXPATHLEN];
- char *dtfsargv[5];
+ char *dtfsargv[6];
pid_t childpid;
int *pflags;
char comfd[16];
@@ -244,14 +252,17 @@
atf_tc_get_config_var(tc, "srcdir"));
dtfsargv[0] = dtfs_path;
dtfsargv[1] = __UNCONST("-i");
- dtfsargv[2] = __UNCONST("dtfs");
- dtfsargv[3] = __UNCONST("fictional");
- dtfsargv[4] = NULL;
+ dtfsargv[2] = __UNCONST("-s");
+ dtfsargv[3] = __UNCONST("dtfs");
+ dtfsargv[4] = __UNCONST("fictional");
+ dtfsargv[5] = NULL;
/* Create sucketpair for communication with the real file server */
if (socketpair(PF_LOCAL, SOCK_STREAM, 0, sv) == -1)
return errno;
+ signal(SIGCHLD, childfail);
+
switch ((childpid = fork())) {
case 0:
close(sv[1]);
@@ -324,7 +335,8 @@
if (rump_sys_mount(MOUNT_PUFFS, path, flags,
pargs->pta_pargs, pargs->pta_pargslen) == -1) {
- printf("%d\n", errno);
+ /* apply "to kill a child" to avoid atf hang (kludge) */
+ kill(pargs->pta_childpid, SIGKILL);
return -1;
}
@@ -357,6 +369,9 @@
{
int rv;
+ /* ok, child might exit here */
+ signal(SIGCHLD, SIG_IGN);
+
rv = rump_sys_unmount(path, flags);
if (rv)
return rv;