Created
January 30, 2015 18:05
-
-
Save hartwork/4a9617cc317ed52f5bce to your computer and use it in GitHub Desktop.
"dd status=progress" substitute for coreutils <8.24
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/env python | |
# Wrapper around dd(1) | |
# .. saving you to run "kill -USR1 <pid>" in another shell | |
# | |
# Copyright (C) 2011 Sebastian Pipping <[email protected]> | |
# 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