l i n u x - u s e r s - g r o u p - o f - d a v i s
Next Meeting:
July 7: Social gathering
Next Installfest:
Latest News:
Jun. 14: June LUGOD meeting cancelled
Page last updated:
2003 Dec 22 10:23

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] Suspending a process by PID
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] Suspending a process by PID

hey nicole,

yeah, sure it's possible.  i'm surprised that sending SIGSTOP/SIGCONT
doesn't work.  but then again, i've never tried that.

anyway, using ptrace() to attach to a process will make the process a
child and suspend it immediately.  you can then step through
instructions, look at memory maps and all kinds of neat stuff.  for
instnace, you can use this kind of thing to cheat at games.  neat stuff.

more than you wanted, but it has the effect you desire (i think).

here's some code i wrote that attaches to a process:

bool Process::attach(void)
   int status;

   if(attached) {
      return true;

   // Request to attach.
   if(ptrace(PTRACE_ATTACH, pid, 0, 0) == -1) {

   // Wait for the child to tell us it worked
   if(waitpid(pid, &status, WUNTRACED) != pid) {
      return false;
   if(!WIFSTOPPED(status)) {
      return false;

   return true;

and detach from the process:

bool Process::detach(void)

   // Fail if we we're unattached.
   if(! attached)
      return false;

   if(attached - 1 == 0) {

      // I don't know why it's supposed to be 1 either. ;)
      if(ptrace(PTRACE_DETACH, pid, 1, 0) == -1) {


   return true;


On Mon 22 Dec 03,  9:57 AM, Nicole TWN <ana.ng@tmbg.org> said:
> Hi gang
> Anyone know how to suspend a process given its PID?
> It seems like it should be possible, via signals or something, but I can't 
> find how.
> Thanks
> --nicole twn
> _______________________________________________
> vox-tech mailing list
> vox-tech@lists.lugod.org
> http://lists.lugod.org/mailman/listinfo/vox-tech

Make everything as simple as possible, but no simpler.  -- Albert Einstein
GPG Instructions: http://www.dirac.org/linux/gpg
GPG Fingerprint: B9F1 6CF3 47C4 7CD8 D33E 70A9 A3B9 1945 67EA 951D
vox-tech mailing list

LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
Sunset Systems
Who graciously hosts our website & mailing lists!