MCPcopy Create free account
hub / github.com/F-Stack/f-stack / TerminateModuleForkChild

Function TerminateModuleForkChild

app/redis-6.2.6/src/module.c:7898–7915  ·  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

7896 * pid matches, and returns C_OK. Otherwise if there is no active module
7897 * child or the pid does not match, return C_ERR without doing anything. */
7898int TerminateModuleForkChild(int child_pid, int wait) {
7899 /* Module child should be active and pid should match. */
7900 if (server.child_type != CHILD_TYPE_MODULE ||
7901 server.child_pid != child_pid) return C_ERR;
7902
7903 int statloc;
7904 serverLog(LL_VERBOSE,"Killing running module fork child: %ld",
7905 (long) server.child_pid);
7906 if (kill(server.child_pid,SIGUSR1) != -1 && wait) {
7907 while(waitpid(server.child_pid, &statloc, 0) !=
7908 server.child_pid);
7909 }
7910 /* Reset the buffer accumulating changes while the child saves. */
7911 resetChildState();
7912 moduleForkInfo.done_handler = NULL;
7913 moduleForkInfo.done_handler_user_data = NULL;
7914 return C_OK;
7915}
7916
7917/* Can be used to kill the forked child process from the parent process.
7918 * child_pid would be the return value of RedisModule_Fork. */

Callers 2

prepareForShutdownFunction · 0.85
RM_KillForkChildFunction · 0.85

Calls 2

killFunction · 0.85
resetChildStateFunction · 0.85

Tested by

no test coverage detected