Skip to content

Instantly share code, notes, and snippets.

View Kamilcuk's full-sized avatar
😀

KamilCuk Kamilcuk

😀
View GitHub Profile
@nicowilliams
nicowilliams / fork-is-evil-vfork-is-good-afork-would-be-better.md
Last active May 18, 2024 14:10
fork() is evil; vfork() is goodness; afork() would be better; clone() is stupid

I recently happened upon a very interesting implementation of popen() (different API, same idea) called popen-noshell using clone(2), and so I opened an issue requesting use of vfork(2) or posix_spawn() for portability. It turns out that on Linux there's an important advantage to using clone(2). I think I should capture the things I wrote there in a better place. A gist, a blog, whatever.

This is not a paper. I assume reader familiarity with fork() in particular and Unix in general, though, of course, I link to relevant wiki pages, so if the unfamiliar reader is willing to go down the rabbit hole, they should be able to come ou

@seraphyn
seraphyn / 00logwatch
Created December 31, 2015 17:53
Encrypt Logwatch with gpg
#!/bin/bash
recipient_email=""
recipient_gpg_pub_key=""
sender_gpg_pub_key=""
file="$(mktemp)"
test -x /usr/share/logwatch/scripts/logwatch.pl || exit 0
/usr/sbin/logwatch --detail high > $file
test -s $file || exit 1
@jsimmons
jsimmons / ring-buffer.c
Created October 4, 2010 13:19
ringbuffer implementation
#include "ring-buffer.h"
#include <stdlib.h>
#include <string.h>
#include <assert.h>
RingBuffer *rb_new(size_t size)
{
RingBuffer *buf = malloc(sizeof(*buf));
assert(buf != NULL);