wait3 (waitpid alias) returns -1 with errno set to ECHILD when it should not

TLDR: you are currently relying on unspecified behaviour of signal(2); use sigaction (carefully) instead. Firstly, SIGCHLD is strange. From the manual page for sigaction; POSIX.1-1990 disallowed setting the action for SIGCHLD to SIG_IGN. POSIX.1-2001 allows this possibility, so that ignoring SIGCHLD can be used to prevent the creation of zombies (see wait(2)). Nevertheless, the historical … Read more

In an operating system, what is the difference between a system call and an interrupt?

Short Answer: They are different things. A system call is call by software running on the OS to services provided by the OS. An interrupt is usually external hardware component notifying the CPU/Microprocessor about an event that needs handling in software (usually a driver). I say usually external, because some interrupts can be raised by … Read more

Make syscall in Python

Libc exposes a function to invoke “custom” syscalls: long syscall(long number, …); syscall() is a small library function that invokes the system call whose assembly language interface has the specified number with the specified arguments. Employing syscall() is useful, for example, when invoking a system call that has no wrapper function in the C library. … Read more

How do sites like codepad.org and ideone.com sandbox your program?

codepad.org has something based on geordi, which runs everything in a chroot (i.e restricted to a subtree of the filesystem) with resource restrictions, and uses the ptrace API to restrict the untrusted program’s use of system calls. See http://codepad.org/about . I’ve previously used Systrace, another utility for restricting system calls. If the policy is set … Read more