// Retrieves the current reading position in a file of any process on linux

Rarely I cross-post messages but for me this information was like a revelation so … have patience.


How to get the current reading position in a file of a process on your machine ?

This information can be useful in an avalanche of circumstances

  • you are importing 10G dump.sql into your new database
  • a friend is downloading your last recorded song (copyright free, obviously ;-) ) from your home web-server and you want to know how many bytes you must still send to him before you can turn off the laptop
  • how long you must wait before a grep command finishes its work

Right Answer

Use cat /proc/<process pid>/fdinfo/<file_handle>


For a demonstration keep this micro-program readdy.c and compile it:

// compile me with gcc -o readdy readdy.c

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int main(int argc, char *argv[])
    int fh, ret = 1;
    char bf[64];

    if ((fh = open(argv[1], O_RDONLY)) < 0)

    ret = 1;
    while(ret) {
        ret = read(fh, bf, 64);

    exit (0);
    return (0);

Run as

$ ./readdy readdy.c

and in another console find its pid with ps.

$ ps ax | grep readdy.c 

on my box I found:

10352 pts/5    S+     0:00 ./readdy readdy.c

I want to investigate about process file handlers with the command

$ ls -l /proc/10352/fd


total 0
lrwx------ 1 nastasi nastasi 64 Jan 28 14:53 0 -> /dev/pts/5
lrwx------ 1 nastasi nastasi 64 Jan 28 14:53 1 -> /dev/pts/5
lrwx------ 1 nastasi nastasi 64 Jan 28 14:50 2 -> /dev/pts/5
lr-x------ 1 nastasi nastasi 64 Jan 28 14:53 3 -> /home/nastasi/src/readdy/readdy.c

at this point I can retrieve the current read position of the file readdy.c with:

$ cat /proc/10352/fdinfo/3

and obtain:

pos:	0
flags:	0100000

return on the console with ./readdy running and press enter key only one time

on the other console type again

$ cat /proc/10352/fdinfo/3

and this time obtain:

pos:	64
flags:	0100000

and so on.

If you have root permissions you can investigate each file opened by each process of your machine.

Simple and powerful.

Wrong Answers

Before this 'discover' I tried 'inotify' file system inquiry software interface but the maximum information level was “someone access the file” without any info about position.

Another tentative was with strace but no info about position are associated with read system call.


No. 1 @ 2016/10/18 11:42

merle pharmacy bloomington il <a href=http://vyvanse.iconosites.com/>buy vyvanse online</a> doctors in my area

No. 2 @ 2016/10/18 11:42

acer iconia a210 tablet <a href=http://fastin.guildomatic.com/>buy fastin online cheap</a> carolina internal medicine greenville sc

No. 3 @ 2016/10/18 11:43

migraine medicine side effects <a href=http://vyvanse.iconosites.com/>buy vyvanse online</a> buy viagra online canada

No. 4 @ 2016/11/11 09:46

doctors care north augusta <a href=http://reductil.creatupropiaweb.com/>comprar reductil online barato</a> christian drug rehab center

No. 5 @ 2016/11/11 09:47

trilogy health services llc <a href=http://reductil.creatupropiaweb.com/>donde comprar reductil en chile 2013</a> online drugstore canada no prescription

No. 6 @ 2016/11/11 09:47

cigna healthcare phoenix az <a href=http://reductil.creatupropiaweb.com/>comprar reductil en chile</a> medicine for cat allergies

No. 7 @ 2016/12/13 18:18

contact lenses without current prescription <a href=http://tramadol.sitego.fr/>acheter tramadol</a> buy codeine syrup online no prescription

No. 8 @ 2016/12/13 18:18

24 hour pharmacy reno nv <a href=http://stilnox.ayosport.com/>acheter stilnox</a> free cialis no prescription

No. 9 @ 2016/12/13 18:19

how to conceive twins with fertility drugs <a href=http://blogscat.com/a/rivotril/>comprar rivotril sin receta</a> first health life & health insurance company

No. 10 @ 2016/12/14 08:36

free health insurance quotes <a href=http://tramadol.favos.nl/>tramadol kopen</a> green contact lenses no prescription

No. 11 @ 2016/12/14 08:36

cleveland clinic weston doctors <a href=http://methylphenidate.eventsbot.com/>buy methylphenidate online</a> sport and health stafford

No. 12 @ 2016/12/14 08:36

west tn healthcare jackson tn <a href=http://ixprim.sitego.fr/>acheter ixprim sur internet</a> virus protection for android tablet

No. 13 @ 2016/12/15 02:09

best eye doctor nyc <a href=http://blogscat.com/a/rivotril/>comprar rivotril</a> alabama department of public health

No. 14 @ 2016/12/15 02:09

stop smoking prescription drugs <a href=http://sibutraminefr.viabloga.com/>acheter sibutramine sans ordonnance</a> mental health technician job description

No. 15 @ 2016/12/15 02:09

orthopaedic and sports medicine <a href=http://reductil.asso-web.com/>acheter reductil en france</a> nexus 7 tablet cases

No. 16 @ 2016/12/15 16:16

united healthcare dental solstice <a href=http://blogscat.com/a/rivotril/>comprar rivotril sin receta</a> benefits of flaxseed oil pills

No. 17 @ 2016/12/15 16:17

medicine for stomach virus <a href=http://methylphenidate.eventsbot.com/>buy methylphenidate</a> quality management in healthcare

No. 18 @ 2016/12/15 16:17

drug and alcohol counselor requirements <a href=http://alvalin.chapso.de/>alvalin kaufen schweiz</a> what are the side effects of viagra

No. 19 @ 2016/12/16 14:21

medicine for back spasms <a href=http://valium.oneminutesite.it/>comprare valium senza ricetta</a> drug testing for welfare states

No. 20 @ 2016/12/16 14:21

get free viagra samples online <a href=http://alvalin.chapso.de/>alvalin kaufen schweiz</a> maui jim prescription sunglasses

No. 21 @ 2016/12/16 14:21

how does the after pill work <a href=http://ixprim.sitego.fr/>acheter ixprim</a> acer iconia tablet accessories

No. 22 @ 2016/12/31 14:27

cvs pharmacy springfield missouri <a href=http://meridia.top-depart.com/>acheter meridia reductil</a> high risk pregnancy doctors in nyc

No. 23 @ 2016/12/31 14:27

sinus medicine for pregnant women <a href=http://concerta.blogse.nl/>concerta kopen in belgie</a> google play store app for nook tablet

No. 24 @ 2016/12/31 14:28

how to know your prescription for glasses <a href=http://rivotril.bloggo.nu/>kjope rivotril</a> wheaton franciscan healthcare racine

No. 25 @ 2017/01/02 22:40

white out prescription contacts <a href=http://xanor.zoomin.se/>kopa xanor billigt</a> doctor who pc game

No. 26 @ 2017/01/02 22:40

society of nuclear medicine <a href=http://concerta.blogse.nl/>concerta kopen</a> how to get help for drug addiction

No. 27 @ 2017/01/02 22:40

topical pain cream prescription <a href=http://www.stesolid.cybersite.nu/>kopa stesolid 10mg</a> cold medicine for 6 month old

No. 28 @ 2017/01/10 11:06

my health intermountain healthcare <a href=http://qsymia.tribalpages.com/>buy qsymia online pharmacy</a> black ant sex pills

No. 29 @ 2017/01/10 11:06

aarp medicare rx plans united healthcare <a href=http://stilnox.1apps.com/>stilnox kaufen bestellen</a> cigna health insurance reviews

No. 30 @ 2017/01/10 11:06

doctor of veterinary medicine degree <a href=http://meridia.top-depart.com/>acheter meridia</a> buy birth control online without prescription

No. 31 @ 2017/01/11 00:23

how much is nook tablet <a href=http://qsymia.guildomatic.com/>buy qsymia canada</a> nuclear medicine gastric emptying study

No. 32 @ 2017/01/11 00:23

great lakes home healthcare services <a href=http://qsymia.guildomatic.com/>buy qsymia online canada</a> free pharmacy tech study guide

No. 33 @ 2017/01/11 00:23

medicine cabinet with mirror <a href=http://temesta.anatoile.com/>acheter temesta en ligne sans ordonnance</a> capital health regional medical center

No. 34 @ 2017/01/15 04:29

Que Es Cialis Super Active Discount Secure Ordering Acticin Direct <a href=http://rx2day.com>buy viagra online</a> Predison No Scrip buy accutane generic

Leave a comment…

  • E-Mail address will not be published.
  • Formatting:
    //italic//  __underlined__
    **bold**  ''preformatted''
  • Links:
    [[http://example.com|Link Text]]
  • Quotation:
    > This is a quote. Don't forget the space in front of the text: "> "
  • Code:
    <code>This is unspecific source code</code>
    <code [lang]>This is specifc [lang] code</code>
    <code php><?php echo 'example'; ?></code>
    Available: html, css, javascript, bash, cpp, …
  • Lists:
    Indent your text by two spaces and use a * for
    each unordered list item or a - for ordered ones.