This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Spawn a process that eats memory by the gigabyte. | |
# Useful for testing ulimits and other such nonsense. | |
if [ $# -ne 1 ]; then | |
echo "Usage: $0 <gigabytes>" | |
exit 1 | |
fi | |
gigabytes_to_allocate=$1 | |
bytes_to_allocate=$((gigabytes_to_allocate * 1024 * 1024 * 1024)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# strace an existing process tree. `strace -f` only follows newly spawned | |
# processes which is not always what you want. | |
import os | |
import sys | |
import subprocess | |
# /proc/[pid]/task/* == directory of threads including self | |
# /proc/[pid]/task/[pid]/children == child processes |