c - Unit testing kill command -


so trying bad , dirty ;)

i want call kill(0, sigkill) in check unittest kill child processes launched test.

ck_assert_int_eq(magic(13), 13); //<- success, cannot stop magic 

if

ck_assert_int_eq(kill(0, sigkill), 0);  

i "test: (after point) received signal 9 (killed)"

are there ways around it? kill(0, sigkill) done in actual code, think if try call destruction function test, going end same error.

int kill(pid_t pid, int sig)

if pid equals 0, sig sent every process in process group of calling process.

source: man 2 kill

you need call kill( child_pid, sigkill), because child_pid == 0 kill parent + child.

pid_t fork(void);

upon successful completion, fork() shall return 0 child process , shall return process id of child process parent process. both processes shall continue execute fork() function. otherwise, -1 shall returned parent process, no child process shall created, , errno shall set indicate error.

source: man 3 fork


Comments