exiting current terminal in a script

0

I have made alias for running certain program and i have put it in .bashrc file. I want to close current terminal inside the script. I've tried this but it is not working.

alias mp='java -jar myprogram.jar & && kill $(echo $$)'

it seems that it can't kill itself. working os is ubuntu 12.04.

muradin

Posted 2014-07-22T12:12:02.873

Reputation: 103

Answers

0

Try this:

alias mp='java -jar myprogram.jar & && kill -SIGHUP $(echo $$)'

I actually didn't try your whole command, but adding -SIGHUP to the kill command did close my terminal.

From the Wikipedia page on Unix signals:

The SIGHUP signal is sent to a process when its controlling terminal is closed. It was originally designed to notify the process of a serial line drop (a hangup). In modern systems, this signal usually means that the controlling pseudo or virtual terminal has been closed.[3] Many daemons will reload their configuration files and reopen their logfiles instead of exiting when receiving this signal.[4] nohup is a command to make a command ignore the signal.

Steve

Posted 2014-07-22T12:12:02.873

Reputation: 518