From: Heesob Park Date: 2008-08-29T11:04:49+09:00 Subject: Re: Unraveling binary data out of the proc filesystem on Solaris 2008/8/29 Daniel Berger : > > > On Aug 28, 7:37 pm, "Heesob Park" wrote: >> 2008/8/26 Daniel Berger : >> >> > On Aug 25, 7:59 pm, "Heesob Park" wrote: >> >> Hi, >> >> >> 2008/8/26 Daniel Berger : >> >> > >> >> I guess you should use lseek and read combination. >> >> > Ruby has no lseek that I'm aware of. I tried an open + seek + read >> > approach, but I get the same result. >> >> Are you unaware IO#sysseek ? sysseek is actualy lseek. >> >> ------------------------------------------------------------- IO#sysseek >> ios.sysseek(offset, whence=SEEK_SET) => integer >> ------------------------------------------------------------------------ >> Seeks to a given _offset_ in the stream according to the value of >> _whence_ (see +IO#seek+ for values of _whence_). Returns the new >> offset into the file. >> >> f = File.new("testfile") >> f.sysseek(-13, IO::SEEK_END) #=> 53 >> f.sysread(10) #=> "And so on." >> >> I guess open + sysseek +sysread will work for you. > > I tried sysseek on RHEL, but couldn't make it work. It's possible I > did something wrong, but I'm not sure what. > > I also see nothing in the lseek or sysseek documentation that says it > doesn't move the file pointer. > Did you check replacing pread with lseek and read combination in C code implementation not working? If then pread is the only way. Regards, Park Heesob