G
G
good_sefore2019-12-10 10:42:17
linux
good_sefore, 2019-12-10 10:42:17

How to close adjacent tab in terminal?

I do it on Linux. Essence of the question: the bash script should open a new tab with the task and check in a loop until one condition is met. As soon as it is executed, the tab should close. Well, or just a running task to stop in this new tab. How to implement this please tell me. The most elementary example if possible. I dug around - I found how to open and start the process in a new tab, but there is no way to stop it later from the main deposit ..

Answer the question

In order to leave comments, you need to log in

5 answer(s)
K
ky0, 2019-12-10
@ky0

You are confusing bash and software that implements terminal functionality. Bash has no tabs.

P
paran0id, 2019-12-10
@paran0id

You can stop a process by sending it a PID signal with the kill utility. The PID can be placed in a file (called a PID file) so that other programs can retrieve it. But this has nothing to do with tabs, as ky0 already said .

S
Saboteur, 2019-12-10
@saboteur_kiev

In bash, you can run a process in the background and get its process ID via the $!
This variable stores the PID of the last child process.
Then you can kill this process with a kill
like this

#!/bin/bash

./other_script.sh &
OTHER_PID=$!
while blablabla; do sleep 1; done
kill $OTHERPID

M
MechanicZelenyy, 2019-12-10
@MechanicZelenyy

Well, I hope you already understood that there are no tabs, but what you need is: run the script using the source command if you want it to run in the current environment, or using the bash command to run it in another environment.
To run in the background, put an & at the end of the command.

G
good_sefore, 2019-12-10
@good_sefore

ky0 , may have described the task incorrectly .. in the Linux terminal I run the bash script written. In it, in fact, the code that opens a tab in this terminal, runs the code in this new tab. The first tab monitors one event with a delay of 1 second in a cycle. As soon as the event occurs, the second tab must be closed. But I don't know what team. What to add there? As I understand it, when opening the second tab, you need to get its id somehow .. so that you can close it later. But how? Or is there another option?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question