Merge "Initial support for DPDK 18.05"
[samplevnf.git] / VNFs / DPPD-PROX / quit.h
1 /*
2 // Copyright (c) 2010-2017 Intel Corporation
3 //
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
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
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.
15 */
16
17 #ifndef _QUIT_H_
18 #define _QUIT_H_
19
20 #include <signal.h>
21 #include <sys/types.h>
22 #include <unistd.h>
23
24 #include <rte_debug.h>
25
26 #include "display.h"
27 #include "prox_cfg.h"
28
29 /* PROX_PANIC for checks that are possibly hit due to configuration or
30    when feature is not implemented. */
31 /* Restore tty and abort if there is a problem */
32 #define PROX_PANIC(cond, ...) do {                                      \
33                 if (cond) {                                             \
34                         plog_info(__VA_ARGS__);                         \
35                         display_end();                                  \
36                         if (prox_cfg.flags & DSF_DAEMON) {              \
37                                 pid_t ppid = getppid();                 \
38                                 plog_info("sending SIGUSR2 to %d\n", ppid);\
39                                 kill(ppid, SIGUSR2);                    \
40                         }                                               \
41                         rte_panic("PANIC at %s:%u, callstack:\n",       \
42                                   __FILE__, __LINE__);                  \
43                 }                                                       \
44         } while (0)
45
46 #endif /* _QUIT_H_ */