xb95's Journal -- Day [entries|friends|calendar]
xb95

[ website | xb95 ]
[ userinfo | scribbld userinfo ]
[ calendar | scribbld calendar ]

pondering linux fd stuff [21 Oct 2008|07:04pm]
Lazyweb:

Does anybody know how to get what the current position is in an open fd? In effect, I'm looking at a process (for example, gzip, tar, cat, etc) and I want to see how far along a file it has read. I can see what file it's in with lsof, I can see what data it's reading with strace, but I can't seem to figure out how to determine how far along it is.

Notably, this would be useful for getting progress indicators on things. Yeah, it's going to be inaccurate for small files due to buffering, but for a large operation it should be reasonably reliable in telling you the general location of the operation.

I've pondered this for a while now and can't think of anything that doesn't involve writing my own kernel module or something that parses the strace output and then tries to find that sequence of bytes in the file (unreliable and inefficient) or just counting the bytes read (strikes me as still inefficient, and doesn't work on an already-started process).

Anybody have any ideas?
post comment

navigation
[ viewing | October 21st, 2008 ]
[ go | previous day|next day ]