1
/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
18
#include "apr_thread_proc.h"
19
#include "apr_errno.h"
20
#include "apr_general.h"
22
#include "apr_strings.h"
24
#if APR_HAS_OTHER_CHILD
26
static char reasonstr[256];
28
static void ocmaint(int reason, void *data, int status)
31
case APR_OC_REASON_DEATH:
32
apr_cpystrn(reasonstr, "APR_OC_REASON_DEATH",
33
strlen("APR_OC_REASON_DEATH") + 1);
35
case APR_OC_REASON_LOST:
36
apr_cpystrn(reasonstr, "APR_OC_REASON_LOST",
37
strlen("APR_OC_REASON_LOST") + 1);
39
case APR_OC_REASON_UNWRITABLE:
40
apr_cpystrn(reasonstr, "APR_OC_REASON_UNWRITEABLE",
41
strlen("APR_OC_REASON_UNWRITEABLE") + 1);
43
case APR_OC_REASON_RESTART:
44
apr_cpystrn(reasonstr, "APR_OC_REASON_RESTART",
45
strlen("APR_OC_REASON_RESTART") + 1);
54
/* It would be great if we could stress this stuff more, and make the test
57
static void test_child_kill(abts_case *tc, void *data)
59
apr_file_t *std = NULL;
61
apr_procattr_t *procattr = NULL;
65
args[0] = apr_pstrdup(p, "occhild" EXTENSION);
66
args[1] = apr_pstrdup(p, "-X");
69
rv = apr_procattr_create(&procattr, p);
70
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
72
rv = apr_procattr_io_set(procattr, APR_FULL_BLOCK, APR_NO_PIPE,
74
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
76
rv = apr_proc_create(&newproc, "./occhild" EXTENSION, args, NULL, procattr, p);
77
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
78
ABTS_PTR_NOTNULL(tc, newproc.in);
79
ABTS_PTR_EQUAL(tc, NULL, newproc.out);
80
ABTS_PTR_EQUAL(tc, NULL, newproc.err);
84
apr_proc_other_child_register(&newproc, ocmaint, NULL, std, p);
86
apr_sleep(apr_time_from_sec(1));
87
rv = apr_proc_kill(&newproc, SIGKILL);
88
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
90
/* allow time for things to settle... */
91
apr_sleep(apr_time_from_sec(3));
93
apr_proc_other_child_refresh_all(APR_OC_REASON_RUNNING);
94
ABTS_STR_EQUAL(tc, "APR_OC_REASON_DEATH", reasonstr);
98
static void oc_not_impl(abts_case *tc, void *data)
100
ABTS_NOT_IMPL(tc, "Other child logic not implemented on this platform");
104
abts_suite *testoc(abts_suite *suite)
106
suite = ADD_SUITE(suite)
108
#if !APR_HAS_OTHER_CHILD
109
abts_run_test(suite, oc_not_impl, NULL);
112
abts_run_test(suite, test_child_kill, NULL);