what process invoke on a.out

Oct 31, 2010 at 1:47pm
When we complie program and excute binary and run the command

./a.out .. than what is process invoke for running the program

does anyone provide me some idea
Oct 31, 2010 at 2:07pm
Not sure what you mean. When you type that on a terminal, it'll be the terminal that invokes the program execution.
a.out is not being interpreted, if that's what you're asking.
Oct 31, 2010 at 3:59pm
I mean when we execute any binary than compiler invoke any process so that program execute and we get expected result.

ex. we wrote simple program for addition of two number. we compile and get binary
and excute program.

Than which process invoke do all operation and give us result.

am i able to convey my message
Oct 31, 2010 at 4:20pm
The compiler produces a binary, that is, a stand-alone executable. It is not "executed"/interpreted by another process.
After a.out has been produced, the compiler has finished its job. It is not involved in running the program in any way, so a.out will run on a machine where no C++ compiler is installed.

You might confuse this with Java or C#. The standard compilers for those do not produce any output that can be run directly on regular processors and therefore these programs must be interpreted by other processes (i.e. java/mono).

Oct 31, 2010 at 4:29pm
The operating system / shell execute the programs / commands you call
Oct 31, 2010 at 6:23pm
so let me sumarize both of you point.

1) I compiled c++ program with g++ in linux I got a.out or any binary name which I gave during compile the program

Ex g++ -o sum sum.cpp

so complier completed all process like compling and linkking and convert into machine code.

2) I have sum binary which I excute in linux like shell or any command.

./sum

So does operating system receive any call to perform this operation. or will it be treat like
any shell script and will it go to kernel and excute the instruction

How the operating system run this program.
Last edited on Oct 31, 2010 at 6:25pm
Oct 31, 2010 at 8:20pm
I thing he's asking how to get the results of his program.

If you are passing the value via a 'return' at the end of main, from a Linux command line you can type:

echo $?

In Windows you can type:

echo %errorlevel%

Alternatively you can use cout (from iostream) or printf (from cstdlib) and have your program print the output itself.
Oct 31, 2010 at 11:40pm
When you run a machine code program the OS will create a process using the machine code of your program and a chunk of system memory. So your a.out program actually forms a part of the running process.
Nov 1, 2010 at 5:45am
Thanks Galik
That's what i was looking . what kind of process OS create to use machine code . what kind of
process invoke when we execute a.out.

Topic archived. No new replies allowed.