#!/bin/bash

if [ $# -lt 1 ]; then
	echo "Usage: $(basename $0) <COMMAND>" >&2
	echo "Run COMMAND in a shell with max available max processes" >&2
	exit 1
fi

max_processes=$(ulimit -Hu)
ulimit -Su ${max_processes}
max_processes=$(ulimit -u)

echo "Running with ${max_processes} max processes: $*" >&2
exec /bin/sh -c "$*"

