[Gllug] file offset in running process

Alain Williams addw at phcomp.co.uk
Fri Aug 14 16:19:30 UTC 2009


On Fri, Aug 14, 2009 at 05:09:21PM +0100, Robert McKay wrote:
> On Fri, Aug 14, 2009 at 4:46 PM, <salsaman at xs4all.nl> wrote:
> 
> >
> >
> > /proc/$pid/fdinfo/$fd has a field called pos:
> >
> > if you grep for this maybe it will return what you are looking for.
> >
> 
> If fdinfo is unavailable on your kernel you can easily get this information
> by calling lseek() through gdb like this;
> ...


> (gdb) call lseek(0, 0, 1)
> $1 = 63
> (gdb) detach
> Detaching from program: /bin/bash, process 18255
> (gdb) quit

You, sir, are a genius! It worked brilliantly although (I ran it again just to test your solution)
gave:
	$1 = -595279360
because I was copying an 8GB memory stick - and I was beyond 2^31.

I note that when copying to a USB stick (one to another) I got 2.4MB/s
but when just reading (to hard disk) I got 16.8MB/s.
I hadn't quite appreciated that difference between write & read speeds.

Regards

-- 
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php
Past chairman of UKUUG: http://www.ukuug.org/
#include <std_disclaimer.h>
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list