delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2011/05/05/00:43:22

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST,T_TO_NO_BRKTS_FREEMAIL
X-Spam-Check-By: sourceware.org
MIME-Version: 1.0
In-Reply-To: <BANLkTin2LqmSCJ8CdjSCNLTiPO8_sOknpg@mail.gmail.com>
References: <BANLkTin2LqmSCJ8CdjSCNLTiPO8_sOknpg AT mail DOT gmail DOT com>
Date: Thu, 5 May 2011 05:42:58 +0100
Message-ID: <BANLkTinhUwnY31oeQipoVaS8nRtC6=Hikw@mail.gmail.com>
Subject: Re: Background processes prevent terminal window from closing
From: Andy Koppe <andy DOT koppe AT gmail DOT com>
To: cygwin AT cygwin DOT com
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On 5 May 2011 05:30, Ryan Dortmans wrote:
> Hi,
>
> I have found that background processes prevent the terminal window
> from closing. I have tried with the cmd terminal as well as mintty.
> Here is a simple example:
>
> $ notepad .profile &
> [1] 10260
> $ exit
> logout
>
> The window remains until I close the notepad window. I have also
> reproduced the issue using a simple looping shell script instead of a
> windows program.
>
> I thought that running disown would detach the process to turn it into
> a daemon, but this has no effect.

No, this just removes it from the shell's job control, but it still
remains connected to the terminal session.

> Is there any way to detach running background processes such that the
> terminal can be closed?

You can start a program in a separate session using the 'setsid'
utility from the util-linux package. I don't know whether it's
possible to detach a running process.

You can close the terminal anyway though using the Close button (or
Alt+F4 in the case of mintty), except of course that the background
process might also be closed, depending on its SIGHUP handling.

Andy

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019