Well my question is the next.. I have a problem programming with c++. I have a program and I need to execute a thread in a new terminal and at the same time keep the old terminal open and interacting with the two terminal. For example taking and printing variables in two terminals independently one of the other. I don't know if it is possible I'm new in the world of programming. Thanks for help me!
Asked
Active
Viewed 769 times
2
-
What have you tried so far? What have you read that suggests this is/isn't possible? – Tas May 13 '16 at 03:16
1 Answers
1
At any given time, only one process is in the foreground of a terminal, and that is the process that will read from standard input.
In shells such as bash, you can use ctrl-z
to stop the current foreground process, then you can use the fg
command to bring it or another process to the foreground.
Here's an example of starting a sleep
command, then opening the python
interactive shell, then switching back to sleep
interactively:
$ sleep 10
^Z
[1]+ Stopped sleep 10
$ python
Python 3.5.0 (default, Jan 18 2016, 00:37:26)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.1.76)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
^Z
[2]+ Stopped python
$ jobs
[1]- Stopped sleep 10
[2]+ Stopped python
$ fg 1
sleep 10
$
If that's the sort of thing you'd like to accomplish, check out this question for information on how to do this using c
.

Community
- 1
- 1

Razzi Abuissa
- 3,337
- 2
- 28
- 29
-
Thanks for your answer. But I don t understand so much. Really I want to do a chat program and I need that my principal terminal write strings (my messages) and in an other terminal y print the messages that arrive from the server (my messages and other contact s messages). Maybe my question is more clean now. – nicoperez May 14 '16 at 00:11
-
Check out posts on interprocess communication / message passing such as http://stackoverflow.com/questions/8900141/message-passing-between-two-programs. – Razzi Abuissa May 15 '16 at 17:23