Questions tagged [exit]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
2 answers
130 views

How do you continue execution after using trap EXIT in bash?

Environment: GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin20) I'm attempting to trap the exit from another function but then continue executing the program. In an object oriented language ...
user avatar
0 votes
0 answers
58 views

EXIT trap is ignored on Ctrl-C when PID == 1

a.sh: trap 'echo cleanup' EXIT sleep 3 To reproduce, press Ctrl-C before the script finishes: $ docker run --rm -itv $PWD:/app -w /app alpine:3.14 sh a.sh ^Ccleanup $ docker run --rm -itv $PWD:/app -...
user avatar
  • 2,893
1 vote
1 answer
74 views

AppImage doesn't run when using "; exit" after the command

I downloaded the AppImage of Syncplay and put it in $HOME/Applications and created an alias in zsh to run it from terminal and then exit. In ~/.zshrc I have, $ grep syncplay ~/.zshrc alias syncplay=&...
user avatar
1 vote
2 answers
56 views

Interpretation of Open Group Base Specification's description of exit()

In the exit() function description of the Open Group Base Specifications (various issues), we read: The exit() function shall first call all functions registered by atexit(), in the reverse order of ...
user avatar
  • 13
-4 votes
1 answer
457 views

Use exit, but do not close terminal, in bash script

I have created a shell function to comfortably use desktop search tool baloosearch. I created it as a function for a reason. Now, in this functions I need to use exit command to quit loops, ifs or ...
user avatar
0 votes
1 answer
148 views

how to exit in bash script from ProFTPD via netcat after some copy operations

I am connecting to a proftpd server via netcat nc 10.10.239.150 21 Then I am doing some copy operations like "The mod_copy module implements SITE CPFR and SITE CPTO commands" After "...
user avatar
0 votes
2 answers
134 views

How do I automatically close the process left behind by a misbehaving application after it exits?

There are applications that do not exit cleanly leaving behind their process. One example I've found is Foxit Reader. Of course, the ideal would be to report a bug and have the application fixed, but ...
user avatar
  • 355
1 vote
0 answers
73 views

Is it possible to exit `podman run -t` if standard input is redirected?

When I run podman run -t "" alpine:3 sh Everything works and is kosher, and I can exit by typing exit, or CONTROL+P, CONTROL+Q. However, if I run podman run -t "" alpine:3 sh <&...
user avatar
  • 22.4k
0 votes
2 answers
772 views

Is the sigspec for 0 EXIT or SIGEXIT or exit?

I need to write a trap which tracks when a process exits (amongst other things) and removes a temporary file. I'd prefer to use the sigspec instead of number for better code readability, the relevant ...
user avatar
0 votes
1 answer
78 views

Can't stop script l loop with exit command

I've got a debug function in my script (that runs via nemo.action) that uses zenith popup to ask if the user want to stop or continue when an error occurs. However, when this happens inside a loop, ...
user avatar
  • 327
3 votes
1 answer
104 views

Bash Shell "onecmd" Option Usage Purpose [duplicate]

I read on man page, but I don't understand the purpose of bash's onecmd option. If I use the set -o onecmd command, the shell immediately exits. My expectation is for it to wait for me to enter one ...
user avatar
  • 1,072
3 votes
2 answers
252 views

How to propagate an error code outside a terminal?

From inside a bash script I try to retrieve the error code of a program launched in a new terminal window. It can be reduced to this: #!/bin/bash urxvt -e bash -c "exit 4" echo $? output: 0 I would ...
user avatar
  • 177
2 votes
1 answer
218 views

Question about a process lifecycle

I've managed to question myself about the wait(2) and _exit(2) system calls in a process lifecycle. My question about the wait(2) system call is... does the parent process issue it to the kernel? Or ...
user avatar
  • 121
5 votes
1 answer
253 views

How do I exit less when reading from stdin when it is called with a single minus argument: "less -"

Is there a proper way to exit less - without having to kill the process? I accidently created a file called - (minus) and tried to view it with: less - Less than follows stdin and I did not find ...
user avatar
4 votes
1 answer
885 views

In bash, how can I retrieve the exit code of a subshell when using local

This question is close to others - Can I get the exit code from a sub shell launched with $(command)? However there are no solutions I've found that allows me to get an exit code from a sub shell ...
user avatar
0 votes
1 answer
942 views

How to follow-up a command with Ctrl + D (EOF)

I would like to run a few commands and give an explicit Ctrl+D, just like, say: ls;pwd;^D Unfortunately, the above doesn't work. I've also tried \04 and 0x4 in place of ^D above as mentioned here. ...
user avatar
1 vote
1 answer
272 views

Perform special action on bash timeout

This question is related only to bash, no ssh or any other tool. I would like to detect a bash timeout, and only a timeout: I am NOT interested in any other exit conditions (exit, EOF, ^D, or ...
user avatar
  • 163
1 vote
1 answer
804 views

nohup exiting with error 125

nohup exits with Error 125 when trying to start a Python script in the background, yet when using wildcards, pointing to the very same file, nohup works. root@rpi_2:/home/pi/shortcuts# nohup -c ...
user avatar
  • 13
6 votes
1 answer
992 views

Running script line by line automatically yet being asked before each line from second line onwards

I work on a script of about 20 lines which I find myself testing time and again by copy-pasting and executing line by line. Instead of copying-pasting each line and hitting Enter to execute, I would ...
user avatar
0 votes
1 answer
200 views

Confusion about how a systemd service is restarted

I am still confused about systemd services being active vs the process still running vs not running etc. Let's say I have the following basic shell script called my_script.sh : #!/bin/sh touch /...
user avatar
32 votes
3 answers
7k views

How can I detect if I'm in a subshell?

I'm trying to write a function to replace the functionality of the exit builtin to prevent myself from exiting the terminal. I have attempted to use the SHLVL environment variable but it doesn't seem ...
user avatar
  • 32.6k
1 vote
2 answers
2k views

Exit shell with running process in foreground

I have a process running the foreground. I am wondering if it's possible to exit Bash, without (of course) killing the foreground process and exiting as usual, and without killing the terminal ...
user avatar
  • 501
3 votes
1 answer
3k views

Does tmux kill-server shut down running applications gracefully?

Using the tmux command kill-server one can immediately shut down the tmux server and close all open tmux windows. How does this affect the processes still running inside the various tmux windows? Will ...
user avatar
3 votes
2 answers
2k views

How to remove "exit" command from Linux shell

I am working on Linux Ubuntu 16.04. In this challenge I want to remove some commands from the Linux shell. Specifically, I want to remove the exit command. I want that if a user will try to exit ...
user avatar
  • 281
0 votes
0 answers
38 views

Ending slogin session with exit command freezes due to PROMPT_COMMAND modification

I recently embedded an "alert" command into my PROMPT_COMMAND to give me a little notify-send screen notification with the exit code of each command (because I always forget to append the alert when a ...
user avatar
  • 31
10 votes
5 answers
6k views

Capture exit code of exit command

I have this in a bash script: exit 3; exit_code="$?" if [[ "$exit_code" != "0" ]]; then echo -e "${r2g_magenta}Your r2g process is exiting with code $exit_code.${r2g_no_color}"; exit "$...
user avatar
5 votes
3 answers
17k views

How can I exit i3 without using a mouse?

Whenever I go to exit i3 a bar shows up on the top giving me the ability to to click Yes, to exit, or X to cancel.
user avatar
  • 22.4k
-1 votes
2 answers
611 views

Unable to terminate a running program / application

I am having trouble terminating applications started from the terminal - for example, I used: cd /usr/bin and ls to determine that the gimp app is here. I then started gimp by typing "gimp" - started ...
user avatar
  • 103
5 votes
1 answer
1k views

What is the differences between "kill -PIPE $$" vs. "exit 1"?

In my Bash script, I used the following syntax in order to exit from the Bash script: kill -PIPE $$ I use it because sometimes in a function or in an internal shell in the script, the exit 1 does ...
user avatar
  • 10.9k
0 votes
1 answer
954 views

Error in grep command to exit from a Unix Script

I have a log file created while running a script. I want to check the same log file for any messages with 'Msg ....' and exit the code except with this 'Msg 2714'. So, I had added the below code ...
user avatar
  • 3
8 votes
1 answer
2k views

exit not terminating the script [duplicate]

exit doesn't terminate the script when error is called.. output Error: Could not resolve localhost after exit script #!/bin/sh resolve_ip (){ if [ -z "$1" ]; then host="localhost" ...
user avatar
  • 1,657
11 votes
2 answers
5k views

Why is vfork() intended to be used when the child process calls exec() or exit() immediately after creation?

Operating System Concepts and APUE say With vfork(), the parent process is suspended, and the child process uses the address space of the parent. Because vfork() does not use copy-on-write, if ...
user avatar
  • 89.7k
2 votes
4 answers
1k views

What exit modes exist in shell-scripting in general and in Bash in particular?

I know that in shell-scripting an "exit" usually means voluntarily or at least successfully terminating a session (or a process within a session) and that there are several different exit modes; the ...
user avatar
1 vote
1 answer
285 views

how to get the stated behaviour for awk's system() command? [duplicate]

I'm calling the sleep command from awk like so: system("sleep 15m") and found that when I interrupt that with CTRL-C it only interrupts the sleep command, not the script. So I tried wrapping the ...
user avatar
  • 38
9 votes
3 answers
12k views

How can I skip the rest of a script without exiting the invoking shell, when sourcing the script?

I have a bash script, where I call exit somewhere to skip the rest of the script when getopts doesn't recognize an option or doesn't find an expected option argument. while getopts ":t:" opt; do ...
user avatar
  • 89.7k
1 vote
2 answers
305 views

Using the value of a variable as an exit code from a script

I can find plenty of information about how to assign the exit code of a script to av variable, but I want to do the opposite: use the value of a variable (defined within a script) as the exit code of ...
user avatar
  • 11
0 votes
0 answers
65 views

Variable assignment exit status

Normally, if has an exit status not zero, execution will continue: false echo 'this will show' If you use set -e, the shell immediately shall exit: set -e false echo 'this will not show' I am ...
user avatar
  • 5,662
1 vote
1 answer
2k views

Quitting telnet on Linux

Standard escape character is CTRL-] on telnet. https://superuser.com/questions/398/how-to-send-the-escape-character-on-os-x-terminal/427#427 says that on Hungarian keyboard it is CTRL-5. On my ...
user avatar
  • 758
0 votes
1 answer
4k views

Exiting Shell Script from if...else

I have a shell script which I want to exit based on the value of a variable ERROR_COUNT. I can either write if [ ${ERROR_COUNT} -gt 0 ] then echo "Exiting unsuccessfully"; exit 1; fi echo "...
user avatar
  • 101
3 votes
3 answers
891 views

How can I get a confirmation before exiting screen?

How can I get a confirmation before I exit screen (when typing exit on the command-line). Is this possible?
user avatar
  • 133
5 votes
1 answer
4k views

Really exit Awk script

Perl and Ruby exit actually exits: $ perl -e 'BEGIN {print 1; exit}; END {print 2}' 1 $ ruby -e 'BEGIN {print 1; exit}; END {print 2}' 1 Not so for Awk: $ awk 'BEGIN {print 1; exit}; END {print 2}'...
user avatar
  • 5,662
7 votes
2 answers
5k views

bash + how to exit from secondary script and from the main script on both time

We run the script script1 from the script script_main script_main: #!/bin/bash /tmp/script1 echo $? sleep 2 echo script ended script1: #!/bin/bash exit 1 As is obvious, script1 exits with exit ...
user avatar
  • 10.9k
10 votes
2 answers
23k views

return value from eval

The bash manual states: eval [arg ...] The args are read and concatenated together into a single com- mand. This command is then read and executed by the shell, and ...
user avatar
  • 861
1 vote
1 answer
960 views

How to resolve [1]+ Exit 1 error?

I want to run four different R codes on linux batch using the following command: nohup R CMD BATCH code_name.R& I could run 2 of the codes on background, but running the other two codes, I get ...
user avatar
  • 11
1 vote
3 answers
1k views

Fail when one command fail in sub-command

I want to execute a command in a list of directories : gradle --build-cache. Additionnly the directory need to start with the string 'Project" and not ending with "Test". I succeed doing that with ...
user avatar
  • 13
3 votes
3 answers
4k views

Difference between `exit;` and `exit $?;`

Is there any difference between these two commands: exec "$(dirname "$0")/suman-shell"; exit $?; and exec "$(dirname "$0")/suman-shell"; exit; is the $? redundant in the first case?
user avatar
1 vote
1 answer
5k views

How to exit out of a 'yes' loop [closed]

Using the command yes you can make a loop in the Linux terminal.  How do you exit out of said loop?  (I tried Ctrl+C but it didn't work).
user avatar
  • 121
2 votes
1 answer
955 views

Closing terminal closes the application called through nohup

As far as I know, nohup signals ignores SIGHUP signal sent by the terminal to the application but the application can change that. I'm running Spotify through the command nohup spotify & and when ...
user avatar
  • 185
5 votes
2 answers
4k views

Why do high exit codes on Linux shells (>= 256) not work as expected?

I discovered a strange behaviour (reproducible with zsh and bash on my system): $ # here everything is still normal $ bash -c 'exit 1';echo $? 1 $ bash -c 'exit 255';echo $? 255 $ zsh -c 'exit 255';...
user avatar
  • 2,106
0 votes
1 answer
93 views

New prompt line not automatically put to command line upon exit code

When submitting jobs, I'm getting Exit codes returned, but I have to hit the return key for them to be printed to the log. 1. prompt_line/location sas query.sas & 2. [1] 66682 3. prompt_line/...
user avatar

1
2 3 4 5