Kill the active module forked child, if there is one active and the * pid matches, and returns C_OK. Otherwise if there is no active module * child or the pid does not match, return C_ERR without doing anything. */
| 8092 | * pid matches, and returns C_OK. Otherwise if there is no active module |
| 8093 | * child or the pid does not match, return C_ERR without doing anything. */ |
| 8094 | int TerminateModuleForkChild(int child_pid, int wait) { |
| 8095 | /* Module child should be active and pid should match. */ |
| 8096 | if (g_pserver->child_type != CHILD_TYPE_MODULE || |
| 8097 | g_pserver->child_pid != child_pid) return C_ERR; |
| 8098 | |
| 8099 | int statloc; |
| 8100 | serverLog(LL_VERBOSE,"Killing running module fork child: %ld", |
| 8101 | (long) g_pserver->child_pid); |
| 8102 | if (kill(g_pserver->child_pid,SIGUSR1) != -1 && wait) { |
| 8103 | while(waitpid(g_pserver->child_pid,&statloc,0) != |
| 8104 | g_pserver->child_pid); |
| 8105 | } |
| 8106 | /* Reset the buffer accumulating changes while the child saves. */ |
| 8107 | resetChildState(); |
| 8108 | moduleForkInfo.done_handler = NULL; |
| 8109 | moduleForkInfo.done_handler_user_data = NULL; |
| 8110 | return C_OK; |
| 8111 | } |
| 8112 | |
| 8113 | /* Can be used to kill the forked child process from the parent process. |
| 8114 | * child_pid would be the return value of RedisModule_Fork. */ |
no test coverage detected