Created
September 22, 2016 03:54
-
-
Save dcoles/4b2f347f11fcf88b5f4b446f6d0d67af to your computer and use it in GitHub Desktop.
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
# Print the number of bytes unread in a fifo. | |
# David Coles <[email protected]> | |
import argparse | |
import ctypes | |
import fcntl | |
import os | |
import sys | |
import termios | |
if __name__ == "__main__": | |
parser = argparse.ArgumentParser() | |
parser.add_argument("path") | |
args = parser.parse_args() | |
fd = os.open(args.path, os.O_RDONLY|os.O_NONBLOCK) | |
size = ctypes.c_int(0) | |
fcntl.ioctl(fd, termios.FIONREAD, size, True) | |
print(size.value) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment