Re: pread() and missing memory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





Peter Jay Salzman wrote:

>Hola,
>
>I have a program which pread()'s /proc/<pid>/mem.  It's similar to
>kcheat, if anybody has seen that program.
>
>Occaisionally, pread() will read less bytes than requested, and I'm not
>talking about hitting EOF, I'm talking about somewhere in the middle of
>the mem file.
>
At the risk of sounding like an idiot, because I am not familiar with 
reading /proc/<pid>/mem and I don't know your level understanding 
either: Many people make the mistake when reading files in *nix of 
thinking that reads are guaranteed not to return until n bytes are read. 
This is not true.  Reads in *nix will read "up to n bytes" and return 
the number of bytes read or -1 on error (even on blocked reads).

Are you getting an error on the pread or are you getting the actual 
number of bytes read?  If you are getting the number of bytes read, have 
you tried looping until you get the number of bytes you are looking for? 
 This is always a good practice when reading and writing files.

Hope this helps.
K.R. Foley

><snip>
>


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux