Skip to content

Instantly share code, notes, and snippets.

@lukaslihotzki
lukaslihotzki / deny-exit.c
Last active December 30, 2024 23:17
Program that denies its own exit using seccomp-bpf.
// Program that denies its own exit using seccomp-bpf, so it will consume 100% CPU forever, unless killed externally.
// Execute this program with strace to see that exiting actually fails.
#include <errno.h>
#include <linux/bpf.h>
#include <linux/filter.h>
#include <linux/seccomp.h>
#include <linux/unistd.h>
#include <signal.h>
#include <stdio.h>
@lukaslihotzki
lukaslihotzki / sea-config.json
Last active November 24, 2023 17:24
Embed binary files into Node SEA by reading them into the snapshot
{
"main": "server-with-assets.js",
"output": "sea-prep.blob",
"useSnapshot": true,
"codeCache": true
}
@lukaslihotzki
lukaslihotzki / polyfill_worklet_import.js
Last active October 1, 2022 14:02
Polyfill to support "import" in worklet scripts in Firefox
const wrappedFunc = Worklet.prototype.addModule;
Worklet.prototype.addModule = async function(url) {
try {
return await wrappedFunc.call(this, url);
} catch (e) {
if (e.name != 'AbortError') {
throw e;
}
// assume error is caused by https://bugzilla.mozilla.org/show_bug.cgi?id=1572644