0

I want to run xterm terminal in C++ to create a Linux process like this

system("xterm -e adb start-server")

The adb process is created but after that command it gets killed. I was trying to solve this problem by using nohup and screen but nothing works. I know that I have to put the adb process into background, but how to do that with xterm?


Edit:

I'm loking for solution that will terminate/close the xterm window, but not the adb process. Later I want to use multiple commands in the same xterm window like

system("xterm -e \"adb start-server; adb connect 192.168.X.XXX;\"");

and all output (and eventually errors) I want to see in the same xterm.

Tom
  • 1,027
  • 2
  • 16
  • 35

1 Answers1

1

You can do it like this:

xterm -e /bin/bash -c "adb start-server; /bin/bash"
fghj
  • 8,898
  • 4
  • 28
  • 56
  • Thanks but that is not really what I was expecting. After running this command the xterm terminal pops up without self terminating. I think that's ok, but now I want to close the xterm window without terminating the adb process, how I would do that? – Tom Jul 16 '14 at 10:20
  • 1
    I can not understand you. After you run adb start-server, and untill you run adb kill-server adb daemon should works, even you close all xterm's on your machine. Try it by hands, for example run xterm, from xterm run another xterm, in that xterm run "adb start-server", close xterm, and in parent xterm run "ps aux | grep adb". – fghj Jul 16 '14 at 14:07
  • Yes it works when I run xterm, and by hands I write there adb start-server. After closing the xterm window, the adb process is still running. The problem is when I run the xterm terminal with the -e option like in my answer. After that adb starts, and gets killed when xterm closes. Maybe I'm doing it wrong, and things like that should be making other way? – Tom Jul 16 '14 at 14:40
  • I just realised that I don't need to run xterm for starting the server, I can make it just like that - system("adb start-server"), and then other commands I can run in xterm ;) Thanks for your help! – Tom Jul 16 '14 at 15:58