Running two processes in parallel with a makefile

I am trying to start both the server and the client to run from a make file:

Purpose:

./server& ./client 

The problem is that server & never returns a control, even if I assume it should work in the background. It continues to listen on a client that is never called because the makefile does not seem to return control from the server. How can I solve this problem ?. without writing an extra goal or scripts?

Relationship Vishal

+7
source share
2 answers

You must do this by combining the commands in one line:

 target: ./server& ./client 

Make command-line command lines ( $(SHELL) ) one line at a time.

Alternatively, you can define two independent goals:

 target: run_server run_client run_server: ./server run_client: ./client 

and run make with the -j option to parallelize the build steps:

 make -j2 

This would not be the most natural solution to run your program (for example, for a test), but works best when you have a large number of build rules that can be partially built in parallel. (For a bit more control over make -s parallellization goals, see also

.NOTPARALLEL

If .NOTPARALLEL is referred to as a target, then this make call will be run in serial, even if the '-j' option is given. Any recursively invoked make command will still run recipes in parallel (unless its make file also contains this target). Any prerequisites for this purpose are ignored.

+9
source

server running in the background. You can put the foreground using the fg command. And then kill it with Ctrl-C

Or maybe this method: killall server

+1
source

All Articles