X-Recipient: archive-cygwin@delorie.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,T_TO_NO_BRKTS_FREEMAIL
X-Spam-Check-By: sourceware.org
MIME-Version: 1.0
In-Reply-To: <iv2fog$69i$1@dough.gmane.org>
References: <iv25no$u76$1@dough.gmane.org>	<CAHWeT-YB1RV+zXtM1+EnNvKVyymsj9BqYHrGe2nEPM25oL+Ypw@mail.gmail.com>	<iv2fog$69i$1@dough.gmane.org>
Date: Wed, 6 Jul 2011 22:01:00 +0100
Message-ID: <CAHWeT-bGKZk9EyT2W-9piwcVy+4xTKVf9kqcvY7B0FURdY4WEQ@mail.gmail.com>
Subject: Re: Unable to disown process
From: Andy Koppe <andy.koppe@gmail.com>
To: cygwin@cygwin.com
Content-Type: text/plain; charset=UTF-8
X-IsSubscribed: yes
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
Precedence: bulk
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id p66L1LIn008547

On 6 July 2011 21:15, Andrew wrote:
> On 7/6/2011 12:12 PM, Andy Koppe wrote:
>> You can use the 'setsid' utility from the util-linux package to invoke
>> a program in its own session, i.e. without connection to the terminal
>> it is invoked from. For example:
>>
>> setsid ssh -NL 1119:news.mozilla.org:119 \
>>          -L 2119:news.gmane.org:119 \
>>          -L 3119:nntp.perl.org:119 \
>>          andrew@defaria.com
>>
>> No need for 'nohup', redirections, backgrounding, or 'disown' with this.
>
> Actually I still need backgrounding as without it my ~/bin/tunnel just hangs
> on the setsid command...

Hmm, I'm afraid I don't know why that happens when setsid is invoked
from a script.

This returns immediately:

$ setsid sleep 10

As does this:

$ bash -c 'setsid sleep 10'

But this doesn't:

$ echo 'setsid sleep 10' > sleep.sh; bash sleep.sh

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


