Delivery-Date: Sat, 09 Aug 2014 17:47:36 -0400
Return-Path: <tor-talk-bounces@lists.torproject.org>
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on moria.seul.org
X-Spam-Level: 
X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,
	RCVD_IN_BL_SPAMCOP_NET,RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD autolearn=ham
	version=3.3.1
X-Original-To: archiver@seul.org
Delivered-To: archiver@seul.org
Received: from eugeni.torproject.org (eugeni.torproject.org [38.229.72.13])
	(using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by khazad-dum.seul.org (Postfix) with ESMTPS id 42DCD1E0AA8;
	Sat,  9 Aug 2014 17:47:35 -0400 (EDT)
Received: from eugeni.torproject.org (localhost [127.0.0.1])
	by eugeni.torproject.org (Postfix) with ESMTP id 0F0BD2EF4A;
	Sat,  9 Aug 2014 21:47:31 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by eugeni.torproject.org (Postfix) with ESMTP id 11EED24830
 for <tor-talk@lists.torproject.org>; Sat,  9 Aug 2014 21:47:27 +0000 (UTC)
X-Virus-Scanned: Debian amavisd-new at eugeni.torproject.org
Received: from eugeni.torproject.org ([127.0.0.1])
 by localhost (eugeni.torproject.org [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id bxpLz2zvknpA for <tor-talk@lists.torproject.org>;
 Sat,  9 Aug 2014 21:47:27 +0000 (UTC)
Received: from whonix.org (whonix.org [92.243.7.197])
 by eugeni.torproject.org (Postfix) with ESMTP id CD96021BC4
 for <tor-talk@lists.torproject.org>; Sat,  9 Aug 2014 21:47:26 +0000 (UTC)
Received: from 127.0.0.1 (tor-exit-node.dnslab.nl [95.211.229.158])
 by whonix.org (Postfix) with ESMTPSA id 771083590
 for <tor-talk@lists.torproject.org>; Sat,  9 Aug 2014 23:47:22 +0200 (CEST)
Message-ID: <53E696E6.5030001@whonix.org>
Date: Sat, 09 Aug 2014 21:47:18 +0000
From: Patrick Schleizer <patrick-mailinglists@whonix.org>
MIME-Version: 1.0
To: tor-talk@lists.torproject.org
References: <53D727D8.7010902@riseup.net> <53DE3C5D.8020200@whonix.org>
 <20140804204904.GA5462@patternsinthevoid.net> <53E38770.4080304@whonix.org>
 <20140808001316.GF23636@patternsinthevoid.net>
In-Reply-To: <20140808001316.GF23636@patternsinthevoid.net>
Subject: Re: [tor-talk] using locally installed Tor in TBB
X-BeenThere: tor-talk@lists.torproject.org
X-Mailman-Version: 2.1.15
Precedence: list
Reply-To: tor-talk@lists.torproject.org
List-Id: "all discussion about theory, design,
 and development of Onion Routing" <tor-talk.lists.torproject.org>
List-Unsubscribe: <https://lists.torproject.org/cgi-bin/mailman/options/tor-talk>, 
 <mailto:tor-talk-request@lists.torproject.org?subject=unsubscribe>
List-Archive: <http://lists.torproject.org/pipermail/tor-talk/>
List-Post: <mailto:tor-talk@lists.torproject.org>
List-Help: <mailto:tor-talk-request@lists.torproject.org?subject=help>
List-Subscribe: <https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-talk>, 
 <mailto:tor-talk-request@lists.torproject.org?subject=subscribe>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: tor-talk-bounces@lists.torproject.org
Sender: "tor-talk" <tor-talk-bounces@lists.torproject.org>

Hi isis!

Thank you a lot for your detailed answer!

isis:
> for second in `seq 1 15` ; do
>     sleep 1
>     if `kill -0 $pid 2>&1 >/dev/null ` ; then
>         wait "$pid"
>         exitcode="$?"
>         printf "Tor Browser exited suddenly! Exit code: %s\n" "$exitcode"
>         exit "$exitcode"
>     else
>         continue
>     fi
> done
> 
> if test -z "${exitcode}" ; then
>     if test -z "$(kill -0 $pid 2>&1 >/dev/null)" ; then
>         printf "Running Tor Browser process (PID %s) in background...\n" "$pid"
>         disown "$pid"
>         exitcode="0"
>     else
>         exitcode="66" # Something odd happened
>     fi
> fi
> 
> exit "$exitcode"

If you plan on using that code again... I'd like to comment...

I find this a pretty non-standard behavior. Running start-tor-browser in
a shell is a bit like typing a command such as "iceweasel", "firefox",
or "torbrowser" in the shell. Usually in Linux world commands don't exit
and keep running in background when started that way. If a user wishes
to have that behavior, they usually add "& disown" to their command, I
think.

So why not go for a simpler, more standard approach, launch it into
background (&); then wait (wait "$pid"); then check return code of wait;
done?

>> - Wouldn't it be better if the script started Firefox using `exec`? (As
>> per best scripting practices [4].)
> 
> 
> In the case of the old (pre TB-3.6.2, before my crazy `wait` code above),
> possibly. But doing so would obviously mean that the `firefox` process and its
> environment would replace the shell. This means that when the `firefox`
> process dies, the shell would disappear (along with any advice, errors, logs
> which had been logged to it, since the old version doesn't log to file).

Good point.

>> If you wish I could do the changes in a github branch if you would be
>> willing to review.
> 
> 
> That sounds great! Just be sure to explain weird shellisms and bashisms with
> code comments or commit messages.
> 
> I also see you have an (somewhat) old tbb-scripts repo. [6] I've got a bunch
> of random hacky tor-related scripts too, for setting up transproxies and
> catching GFW garbage probes, [7] verifying gitian builder scripts, [8] doing
> all your DNS on a remote Tor relay (through tor, with DNSSEC validation and
> caching), [9] etc. I know Ximin's (infinity0) got some nice hacky scripts too,
> and meejah, perhaps we should all join forces and create a tor-hacks repo?

Sounds good.

All the best,
Patrick

-- 
tor-talk mailing list - tor-talk@lists.torproject.org
To unsubscribe or change other settings go to
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-talk

