Closing a Specific Terminal
I have a program that opens a new terminal and runs while loop, but when the program ends I want to terminate this window. Is it possible to close a certain terminal window with a command, while keeping all other terminals open?
14.04 gnome-terminal
add a comment |
I have a program that opens a new terminal and runs while loop, but when the program ends I want to terminate this window. Is it possible to close a certain terminal window with a command, while keeping all other terminals open?
14.04 gnome-terminal
add a comment |
I have a program that opens a new terminal and runs while loop, but when the program ends I want to terminate this window. Is it possible to close a certain terminal window with a command, while keeping all other terminals open?
14.04 gnome-terminal
I have a program that opens a new terminal and runs while loop, but when the program ends I want to terminate this window. Is it possible to close a certain terminal window with a command, while keeping all other terminals open?
14.04 gnome-terminal
14.04 gnome-terminal
asked Jul 7 '16 at 19:43
Unnecessary BeesUnnecessary Bees
133
133
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Njap
The easy way: Create a variable that the while loop tests for true (or false, whatever way you like) and change this var to end the loop.
The complicated way:
Get the Pid of you Shell:
$ echo $$
returns e.g.
1441
The Shell (e.g. bash) runs in the Terminal, so the Terminal is identified by bashs parent PID. Get ppid:
$ cat /proc/1441/status | grep PPid
returns e.g.
1432
If you can Pid it, you can kill it. ;)
$ kill 1432
EDIT: There might be easier ways to get the Pid of the program process, e.g. if the program has a specific name, you can
$ ps aux | grep nameofmyspecificprogram
for it.
Usepgrep
andpkill
. And use code formatting.
– grooveplex
Jul 7 '16 at 20:03
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f796118%2fclosing-a-specific-terminal%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Njap
The easy way: Create a variable that the while loop tests for true (or false, whatever way you like) and change this var to end the loop.
The complicated way:
Get the Pid of you Shell:
$ echo $$
returns e.g.
1441
The Shell (e.g. bash) runs in the Terminal, so the Terminal is identified by bashs parent PID. Get ppid:
$ cat /proc/1441/status | grep PPid
returns e.g.
1432
If you can Pid it, you can kill it. ;)
$ kill 1432
EDIT: There might be easier ways to get the Pid of the program process, e.g. if the program has a specific name, you can
$ ps aux | grep nameofmyspecificprogram
for it.
Usepgrep
andpkill
. And use code formatting.
– grooveplex
Jul 7 '16 at 20:03
add a comment |
Njap
The easy way: Create a variable that the while loop tests for true (or false, whatever way you like) and change this var to end the loop.
The complicated way:
Get the Pid of you Shell:
$ echo $$
returns e.g.
1441
The Shell (e.g. bash) runs in the Terminal, so the Terminal is identified by bashs parent PID. Get ppid:
$ cat /proc/1441/status | grep PPid
returns e.g.
1432
If you can Pid it, you can kill it. ;)
$ kill 1432
EDIT: There might be easier ways to get the Pid of the program process, e.g. if the program has a specific name, you can
$ ps aux | grep nameofmyspecificprogram
for it.
Usepgrep
andpkill
. And use code formatting.
– grooveplex
Jul 7 '16 at 20:03
add a comment |
Njap
The easy way: Create a variable that the while loop tests for true (or false, whatever way you like) and change this var to end the loop.
The complicated way:
Get the Pid of you Shell:
$ echo $$
returns e.g.
1441
The Shell (e.g. bash) runs in the Terminal, so the Terminal is identified by bashs parent PID. Get ppid:
$ cat /proc/1441/status | grep PPid
returns e.g.
1432
If you can Pid it, you can kill it. ;)
$ kill 1432
EDIT: There might be easier ways to get the Pid of the program process, e.g. if the program has a specific name, you can
$ ps aux | grep nameofmyspecificprogram
for it.
Njap
The easy way: Create a variable that the while loop tests for true (or false, whatever way you like) and change this var to end the loop.
The complicated way:
Get the Pid of you Shell:
$ echo $$
returns e.g.
1441
The Shell (e.g. bash) runs in the Terminal, so the Terminal is identified by bashs parent PID. Get ppid:
$ cat /proc/1441/status | grep PPid
returns e.g.
1432
If you can Pid it, you can kill it. ;)
$ kill 1432
EDIT: There might be easier ways to get the Pid of the program process, e.g. if the program has a specific name, you can
$ ps aux | grep nameofmyspecificprogram
for it.
edited Mar 9 at 12:34
Kulfy
4,89151743
4,89151743
answered Jul 7 '16 at 19:59
Lord_PedantenSteinLord_PedantenStein
36216
36216
Usepgrep
andpkill
. And use code formatting.
– grooveplex
Jul 7 '16 at 20:03
add a comment |
Usepgrep
andpkill
. And use code formatting.
– grooveplex
Jul 7 '16 at 20:03
Use
pgrep
and pkill
. And use code formatting.– grooveplex
Jul 7 '16 at 20:03
Use
pgrep
and pkill
. And use code formatting.– grooveplex
Jul 7 '16 at 20:03
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f796118%2fclosing-a-specific-terminal%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown