Linux Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsOperating SystemsLinux Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 6th, 2011, 04:47 AM
sternr sternr is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2011
Posts: 2 sternr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 m 38 sec
Reputation Power: 0
Reading proc/pid/mem File

Hi, I'm trying to read a process's proc/pid/mem file but with no luck.

While open succeeds, no matter what I try - read always returns -1.

Any ideas?

Thanks!

--sternr

Reply With Quote
  #2  
Old February 8th, 2011, 03:54 PM
crustymonkey's Avatar
crustymonkey crustymonkey is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Minneapolis, MN
Posts: 356 crustymonkey User rank is Corporal (100 - 500 Reputation Level)crustymonkey User rank is Corporal (100 - 500 Reputation Level)crustymonkey User rank is Corporal (100 - 500 Reputation Level)crustymonkey User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 Days 13 h 38 m 46 sec
Reputation Power: 11
What exactly are you trying to do with that? From what I've read, that file can only be read if the process is halted:

http://forum.kernelnewbies.org/read...210,210,quote=1

Are you actually trying to examine the process' memory allocations?
__________________
badger badger badger badger
badger badger badger badger
MUSHROOM MUSHROOM

Reply With Quote
  #3  
Old February 20th, 2011, 06:25 AM
sternr sternr is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2011
Posts: 2 sternr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 m 38 sec
Reputation Power: 0
Yes, to be more specific - the process's stack.

My code uses the ptrace attach API before trying to read the file to force the process to halt.

But still no matter what I try I dont seem to be able to read the other process's stack, even when I'm running as root and the target process is my child process.

Any ideas?
Are there any alternatives for reading process's stack?
(not including ptrace, as it allows reading one word at a time)

Thanks!

--sternr

Reply With Quote
  #4  
Old February 23rd, 2011, 03:30 PM
crustymonkey's Avatar
crustymonkey crustymonkey is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Minneapolis, MN
Posts: 356 crustymonkey User rank is Corporal (100 - 500 Reputation Level)crustymonkey User rank is Corporal (100 - 500 Reputation Level)crustymonkey User rank is Corporal (100 - 500 Reputation Level)crustymonkey User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 Days 13 h 38 m 46 sec
Reputation Power: 11
Well, first off, if you are looking to examine the stack, have you tried just using gdb? Here's a mac developer article that seems to cover a lot of the basics (mac or linux shouldn't make any real difference here):

http://developer.apple.com/library/.../gdb/gdb_7.html

Another option might be to just to manually send it a SIGSTOP (or simply CTRL-Z if you are running it in a shell) and see if you can open the file(s).

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsLinux Help > Reading proc/pid/mem File

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap