The Daily Build

Icon

Software Development, version 3.0

An Interesting pid File Race

ISC’s dhcpd uses this code to check for an already-running daemon:
/* Read previous pid file. */
if ((i = open (path_dhcpd_pid, O_RDONLY)) >= 0) {
status = read (i, pbuf, (sizeof pbuf) – 1);
close (i);
if (status > 0) {
[...]

Read the rest of this entry »

Hassle Free Way to Kill Sudo’d Jobs

Every now and then I have to run a foreground job under sudo that doesn’t want to die when I hit ^C. Then it’s a hassle to ^Z, get the pid of the sudo job, and sudo kill that pid.
So I wrote a little script (or a template for scripts) that runs the sudo job [...]

Read the rest of this entry »

Using Python’s ctypes to Call Into C Libraries

The ctypes module makes loading and calling into a dynamic library incredibly easy.

Read the rest of this entry »