summaryrefslogtreecommitdiff
path: root/test/testoc.c
diff options
context:
space:
mode:
authorRyan Bloom <rbb@apache.org>2000-04-04 20:26:36 +0000
committerRyan Bloom <rbb@apache.org>2000-04-04 20:26:36 +0000
commit06e43f5863614aef8ee7e4dbe3d6be929c726780 (patch)
treecbea2f07b3148b726fbeea493bbad1cf08f775a4 /test/testoc.c
parent0c02c422ed4ba5f7c61e0157500aaeafa58d0720 (diff)
downloadapr-06e43f5863614aef8ee7e4dbe3d6be929c726780.tar.gz
Other child logic finished for Unix. Docs are forthcoming. This should
for Apache, and those patches are also coming today. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@59785 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test/testoc.c')
-rw-r--r--test/testoc.c129
1 files changed, 129 insertions, 0 deletions
diff --git a/test/testoc.c b/test/testoc.c
new file mode 100644
index 000000000..a4a02405e
--- /dev/null
+++ b/test/testoc.c
@@ -0,0 +1,129 @@
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2000 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+#include "apr_thread_proc.h"
+#include "apr_errno.h"
+#include "apr_general.h"
+#include "apr_lib.h"
+#include "errno.h"
+#include <stdio.h>
+#ifdef BEOS
+#include <unistd.h>
+#endif
+
+void ocmaint(int reason, void *data)
+{
+ switch (reason) {
+ case APR_OC_REASON_DEATH:
+ fprintf(stdout, "OC killed... correctly\n");
+ break;
+ case APR_OC_REASON_LOST:
+ case APR_OC_REASON_UNWRITABLE:
+ case APR_OC_REASON_RESTART:
+ fprintf(stdout, "OC maintentance called for reason other than death\n");
+ break;
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ ap_context_t *context;
+ ap_context_t *cont2;
+ ap_status_t status = 0;
+ ap_ssize_t nbytes = 0;
+ ap_proc_t *newproc = NULL;
+ ap_procattr_t *procattr = NULL;
+ char *args[3];
+
+ if (argc > 1) {
+ while (1);
+ }
+
+ if (ap_initialize() != APR_SUCCESS) {
+ fprintf(stderr, "Couldn't initialize.");
+ exit(-1);
+ }
+ atexit(ap_terminate);
+ if (ap_create_context(&context, NULL) != APR_SUCCESS) {
+ fprintf(stderr, "Couldn't allocate context.");
+ exit(-1);
+ }
+
+ args[0] = ap_pstrdup(context, "testoc");
+ args[1] = ap_pstrdup(context, "-X");
+ args[2] = NULL;
+
+ fprintf(stdout, "Creating procattr.......");
+ if (ap_createprocattr_init(&procattr, context) != APR_SUCCESS) {
+ fprintf(stderr, "Could not create attr\n");
+ exit(-1);;
+ }
+
+ fprintf(stdout, "starting other child.......");
+ if (ap_create_process(&newproc, "../testoc", args, NULL, procattr, context)
+ != APR_SUCCESS) {
+ fprintf(stderr, "error starting other child\n");
+ exit(-1);
+ }
+ fprintf(stdout, "OK\n");
+
+ ap_register_other_child(newproc, ocmaint, NULL, -1, context);
+
+ ap_kill(newproc, SIGKILL);
+
+ check_other_child();
+
+ return 1;
+}
+