![]() |
|
|||
0001 /** 0002 * @brief Test default sigchld handler from the server process - server 0003 * 0004 * @file atmisv94.c 0005 */ 0006 /* ----------------------------------------------------------------------------- 0007 * Enduro/X Middleware Platform for Distributed Transaction Processing 0008 * Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved. 0009 * Copyright (C) 2017-2023, Mavimax, Ltd. All Rights Reserved. 0010 * This software is released under one of the following licenses: 0011 * AGPL (with Java and Go exceptions) or Mavimax's license for commercial use. 0012 * See LICENSE file for full text. 0013 * ----------------------------------------------------------------------------- 0014 * AGPL license: 0015 * 0016 * This program is free software; you can redistribute it and/or modify it under 0017 * the terms of the GNU Affero General Public License, version 3 as published 0018 * by the Free Software Foundation; 0019 * 0020 * This program is distributed in the hope that it will be useful, but WITHOUT ANY 0021 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 0022 * PARTICULAR PURPOSE. See the GNU Affero General Public License, version 3 0023 * for more details. 0024 * 0025 * You should have received a copy of the GNU Affero General Public License along 0026 * with this program; if not, write to the Free Software Foundation, Inc., 0027 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 0028 * 0029 * ----------------------------------------------------------------------------- 0030 * A commercial use license is available from Mavimax, Ltd 0031 * contact@mavimax.com 0032 * ----------------------------------------------------------------------------- 0033 */ 0034 #include <stdio.h> 0035 #include <stdlib.h> 0036 #include <ndebug.h> 0037 #include <atmi.h> 0038 #include <ndrstandard.h> 0039 #include <ubf.h> 0040 #include <test.fd.h> 0041 #include <string.h> 0042 #include <unistd.h> 0043 #include <sys/types.h> 0044 #include <sys/wait.h> 0045 #include <signal.h> 0046 #include "test94.h" 0047 0048 /*---------------------------Externs------------------------------------*/ 0049 /*---------------------------Macros-------------------------------------*/ 0050 /*---------------------------Enums--------------------------------------*/ 0051 /*---------------------------Typedefs-----------------------------------*/ 0052 /*---------------------------Globals------------------------------------*/ 0053 /*---------------------------Statics------------------------------------*/ 0054 exprivate int volatile M_got_sig = EXFALSE; 0055 /*---------------------------Prototypes---------------------------------*/ 0056 0057 /** 0058 * Check that we actually got the signal 0059 */ 0060 void sig_handler(int sig) 0061 { 0062 M_got_sig=EXTRUE; 0063 } 0064 0065 /** 0066 * Standard service entry 0067 */ 0068 void TESTSV (TPSVCINFO *p_svc) 0069 { 0070 int ret=EXSUCCEED; 0071 char testbuf[1024]; 0072 pid_t pid, pid_ret; 0073 UBFH *p_ub = (UBFH *)p_svc->data; 0074 int status; 0075 0076 NDRX_LOG(log_debug, "%s got call", __func__); 0077 0078 /* Just print the buffer */ 0079 Bprint(p_ub); 0080 0081 /* test forking + sigchld... */ 0082 pid = ndrx_fork(); 0083 if (pid == 0) 0084 { 0085 NDRX_LOG(log_debug, "Child %d", getpid()); 0086 exit(EXIT_SUCCESS); 0087 } 0088 0089 sleep(5); 0090 0091 pid_ret = waitpid(pid, &status, 0); 0092 0093 if (pid_ret!=pid) 0094 { 0095 NDRX_LOG(log_error, "expected waitpid ret %d got %d", 0096 (int)pid, (int)pid_ret); 0097 ret=EXFAIL; 0098 goto out; 0099 } 0100 0101 if (!M_got_sig) 0102 { 0103 NDRX_LOG(log_error, "No sig arrived"); 0104 ret=EXFAIL; 0105 goto out; 0106 } 0107 0108 out: 0109 tpreturn( ret==EXSUCCEED?TPSUCCESS:TPFAIL, 0110 0L, 0111 (char *)p_ub, 0112 0L, 0113 0L); 0114 } 0115 0116 /** 0117 * Do initialisation 0118 */ 0119 int NDRX_INTEGRA(tpsvrinit)(int argc, char **argv) 0120 { 0121 int ret = EXSUCCEED; 0122 struct sigaction sa; 0123 sigset_t ss; 0124 NDRX_LOG(log_debug, "tpsvrinit called"); 0125 0126 if (EXSUCCEED!=tpadvertise("TESTSV", TESTSV)) 0127 { 0128 NDRX_LOG(log_error, "Failed to initialise TESTSV!"); 0129 EXFAIL_OUT(ret); 0130 } 0131 0132 sigemptyset(&ss); 0133 sa.sa_handler = sig_handler; 0134 sa.sa_mask = ss; 0135 sa.sa_flags = 0; 0136 sigaction(SIGCHLD, &sa, NULL); 0137 0138 out: 0139 return ret; 0140 } 0141 0142 /** 0143 * Do de-initialisation 0144 */ 0145 void NDRX_INTEGRA(tpsvrdone)(void) 0146 { 0147 NDRX_LOG(log_debug, "tpsvrdone called"); 0148 } 0149 0150 /* vim: set ts=4 sw=4 et smartindent: */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |