summaryrefslogtreecommitdiff
path: root/tests/modules
diff options
context:
space:
mode:
Diffstat (limited to 'tests/modules')
-rw-r--r--tests/modules/fork.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/tests/modules/fork.c b/tests/modules/fork.c
index 44e3971bd..d7a0d154f 100644
--- a/tests/modules/fork.c
+++ b/tests/modules/fork.c
@@ -23,7 +23,8 @@ void done_handler(int exitcode, int bysignal, void *user_data) {
int fork_create(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
{
long long code_to_exit_with;
- if (argc != 2) {
+ long long usleep_us;
+ if (argc != 3) {
RedisModule_WrongArity(ctx);
return REDISMODULE_OK;
}
@@ -34,20 +35,22 @@ int fork_create(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
}
RedisModule_StringToLongLong(argv[1], &code_to_exit_with);
+ RedisModule_StringToLongLong(argv[2], &usleep_us);
exitted_with_code = -1;
- child_pid = RedisModule_Fork(done_handler, (void*)0xdeadbeef);
- if (child_pid < 0) {
+ int fork_child_pid = RedisModule_Fork(done_handler, (void*)0xdeadbeef);
+ if (fork_child_pid < 0) {
RedisModule_ReplyWithError(ctx, "Fork failed");
return REDISMODULE_OK;
- } else if (child_pid > 0) {
+ } else if (fork_child_pid > 0) {
/* parent */
+ child_pid = fork_child_pid;
RedisModule_ReplyWithLongLong(ctx, child_pid);
return REDISMODULE_OK;
}
/* child */
RedisModule_Log(ctx, "notice", "fork child started");
- usleep(500000);
+ usleep(usleep_us);
RedisModule_Log(ctx, "notice", "fork child exiting");
RedisModule_ExitFromChild(code_to_exit_with);
/* unreachable */