-5

I want to know can I run some compiled C program for example main.exe with option, that make sleep it after program work? Or can I run immediatly second program and using process, which running with main.exe? I need to calculate memory of process, when I do it in background /proc/[pid]/status and ps aux show me incorrect values, because main.exe works so fast. Or may be I can exec 2 programs in C using one fork()? Or can make option for execv or execl?

too honest for this site
  • 12,050
  • 4
  • 30
  • 52

2 Answers2

1

In Linux, time command can be used to calculate execution time, memory usage, etc

Refer http://linux.die.net/man/1/time

Usage ::

$ time main.exe
Jeyaram
  • 9,158
  • 7
  • 41
  • 63
0

If you have access to source code of your application just insert code to send signal SIGSTOP to itself at the point you want to measure:

 raise( SIGSTOP );

then you can measure whatever you want and let program go by sending SIGCONT from outside. If you do not have such access you may try to run this process and send signal outside, for example by shell script, but you would need to play with delay:

#!/bin/bash
./main.exe &
sleep 0.1 # this may not work on your distro, you will need to find how to sleep subsecond
kill -SIGSTOP %1
Slava
  • 43,454
  • 1
  • 47
  • 90