Skip to content

Instantly share code, notes, and snippets.

@kotakanbe
kotakanbe / ipcalc.go
Created September 17, 2015 02:59
get all IP address from CIDR in golang
package main
import (
"net"
"os/exec"
"github.com/k0kubun/pp"
)
func Hosts(cidr string) ([]string, error) {
@LLFourn
LLFourn / docker_PID1.sh
Last active August 10, 2023 13:37
Docker, Getting around PID 1
# So you want to pipe shell scripts to docker. But docker runs the container's command as PID 1.
# Linux doesn't set up signal handlers for PID 1.
# This gives you the following problems:
# 1. The script can't kill itself:
echo 'kill $$; echo "Still alive"' | docker run -i --rm alpine sh
# 2. You can't kill the script from outside with a normal kill:
echo "sleep 1000" | docker run -i --rm alpine sh & sleep 1 && kill $!
docker ps # it didn't die
#==== Solving problem 1 ====