Home > Bash, Linux > Spåra processer och vad som sker

Spåra processer och vad som sker

November 27th, 2010 Leave a comment Go to comments

You could use strace to see what system calls your program is making …

strace -p PID

You can find out the PID of the process like this:

ps -ef | grep program_name

Example output:

read(3, "V4 DUF602 domain-containing prot"..., 8191) = 8191

writev(6, [{"\0\f\4\20\22\22\17\5\v\v\1\17\t\5\17\5\n\20\20\20\17\4\1\5\1\5\1\
20\21\5\20\20"..., 6330}, {"\f\22\21\t\21\17\22\21\7\v\n\16\17\7\17\21\21\22\
21\21\21\1\21\16\17\7\10\21\16\22\21\21"..., 1520}], 2) = 7850

Now, if you look closely you could tell how much of the job has been done, and how much of the job is left. You know what data it read from which file (the first param in read() is a file descriptor … you can identify the files by going in the /proc/PID/fd folder and doing a “ls -l” … you will see symbolic links  to the actual files … there you will have at least a link named 1 (stdin), 2 (stderr), 3 (the file from which your program reads) and 6 (the file your program writes to))

Categories: Bash, Linux Tags:
  1. No comments yet.
  1. No trackbacks yet.