Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 03-21-2011, 11:14 PM   #1
LQ Newbie
Registered: Mar 2011
Posts: 3

Rep: Reputation: 1
Unhappy ptrace of vsftpd hangs

I am trying to ptrace a vsftpd server process on linux to be able to get control whenever vsftpd process makes a system call. I start the vsftpd process and pass this process id as command line to the following program which traces vsftpd.

however, when I run the following program it just hangs and does not print anything.Can anyone point out what could be wrong? Thanks a lot for your help!!

#include <sys/ptrace.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <linux/user.h>
#include <sys/syscall.h> /* For SYS_write etc */
int main(int argc,char* argv[])
{ pid_t child;
long orig_eax, eax;
long params[3];
int status;
int insyscall = 0;
child = atoi(argv[1]);
while(1) {
orig_eax = ptrace(PTRACE_PEEKUSER,
child, 4 * ORIG_EAX, NULL);

if(orig_eax == __NR_clone || orig_eax == __NR_open || orig_eax == __NR_write)
if(insyscall == 0) {
/* Syscall entry */
insyscall = 1;
params[0] = ptrace(PTRACE_PEEKUSER,
child, 4 * EBX,
params[1] = ptrace(PTRACE_PEEKUSER,
child, 4 * ECX,
params[2] = ptrace(PTRACE_PEEKUSER,
child, 4 * EDX,
if(orig_eax == __NR_clone)
else if(orig_eax == __NR_open)
else if(orig_eax == __NR_write)
printf(" called with "
"%ld, %ld, %ld\n",
params[0], params[1],
else { /* Syscall exit */
eax = ptrace(PTRACE_PEEKUSER,
child, 4 * EAX, NULL);
printf("Returned "
"with %ld\n", eax);
insyscall = 0;
child, NULL, NULL);

return 0;
Old 03-23-2011, 11:31 AM   #2
Senior Member
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 233Reputation: 233Reputation: 233
Over a week & no replies.

Perhaps editing your post to put your code in "Code:" blocks would make it easier to read & help you get the help you're looking for.

In addition, this thread might do better in Programming. You can ask to have it moved by using the "Report" button in the lower right corner of your post & asking "Please move to Programming" or even "pls mv2 Programming"


Last edited by archtoad6; 03-23-2011 at 11:36 AM.


ptrace, vsftpd

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
ptrace attach to vsftpd hangs vbser Linux - Newbie 2 03-22-2011 03:39 AM
[SOLVED] VSFTPD hangs on LIST command ! teamer Linux - Networking 5 06-01-2010 06:21 AM
Ptrace - Help me undersatnd Ptrace jiikka Linux - General 3 03-19-2009 02:33 AM
vsftpd - client hangs trying to LIST badbunny Linux - Networking 7 10-26-2007 07:39 AM
ptrace jucovschi Programming 0 08-28-2003 03:20 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:53 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration