Skip to content

Instantly share code, notes, and snippets.

@hartwork
Created January 30, 2015 18:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hartwork/4a9617cc317ed52f5bce to your computer and use it in GitHub Desktop.
Save hartwork/4a9617cc317ed52f5bce to your computer and use it in GitHub Desktop.
"dd status=progress" substitute for coreutils <8.24
#! /usr/bin/env python
# Wrapper around dd(1)
# .. saving you to run "kill -USR1 <pid>" in another shell
#
# Copyright (C) 2011 Sebastian Pipping <sebastian@pipping.org>
# Licensed under GPL v3 or later
#
# 2011-02-23 04:48 UTC+1
import subprocess
import time
import sys
import signal
import os
args = ["dd", ] + sys.argv[1:]
p = subprocess.Popen(args)
try:
p.poll()
while p.returncode is None:
time.sleep(1)
os.kill(p.pid, signal.SIGUSR1)
p.poll()
except KeyboardInterrupt as e:
os.kill(p.pid, signal.SIGINT)
p.poll()
finally:
sys.exit(p.returncode)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment