phoenix-rtos/phoenix-rtos-project

kill: implement `pid == -1` and `pid == 0` cases for tkill system call

Open

#1,692 opened on Jul 9, 2026

View on GitHub
 (3 comments) (0 reactions) (0 assignees)C (48 forks)auto 404
POSIXgood first issuekernel

Repository metrics

Stars
 (62 stars)
PR merge metrics
 (PR metrics pending)

Description

Category

POSIX_NONCOMPLIANCE

Description

kill() returns -ESRCH and -ENOSYS respectively for pid == -1 and pid == 0. It should do the proper action described below.

Expected behavior

kill(-1, SIGCHLD) sends SIGCHLD signal to all processes (to which the caller is permitted to send signals) with the same PGID as the caller and returns 0.

kill(0, SIGCHLD) sends SIGCHLD signal to all processes (to which the caller is permitted to send signals) and returns 0.

Actual behavior

kill(-1, SIGCHLD) returns -1 with errno set to -ESRCH.

kill(0, SIGCHLD) returns -1 with errno set to -ENOSYS.

POSIX requirement

POSIX.1-2017 (IEEE Std 1003.1-2017), kill()(3p): "If pid is 0, sig shall be sent to all processes (excluding an unspecified set of system processes) whose process group ID is equal to the process group ID of the sender, and for which the process has permission to send a signal.

If pid is -1, sig shall be sent to all processes (excluding an unspecified set of system processes) for which the process has permission to send that signal."

Minimal reproduction code

#include <stdio.h>
#include <signal.h>
#include <errno.h>
#include <string.h>


int main(void)
{
    int ret;

    errno = 0;

    ret = kill(0, SIGCHLD);
    printf("kill(0, SIGCHLD) = %d, errno = %d (%s)\n", ret, errno, strerror(errno));

    ret = kill(-1, SIGCHLD);
    printf("kill(-1, SIGCHLD) = %d, errno = %d (%s)\n", ret, errno, strerror(errno));

    return 0;
}

Host behavior

kill(0, SIGCHLD) = 0, errno = 0 (Success)
kill(-1, SIGCHLD) = 0, errno = 0 (Success)

Revision

Discovered on 0d8d2835fc575c1a20e29b257f4a1241fa05b748

Target

Reproduced on ia32-generic-qemu, not tested on other targets yet.

Related tests

None for now as this is a new feature

Contributor guide