MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / TerminateModuleForkChild

Function TerminateModuleForkChild

src/module.cpp:8094–8111  ·  view source on GitHub ↗

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. */

Source from the content-addressed store, hash-verified

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. */
8094int 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. */

Callers 2

prepareForShutdownFunction · 0.85
RM_KillForkChildFunction · 0.85

Calls 2

serverLogFunction · 0.85
resetChildStateFunction · 0.85

Tested by

no test coverage detected