[tor-talk] using locally installed Tor in TBB

Patrick Schleizer patrick-mailinglists at whonix.org
Sat Aug 9 21:47:18 UTC 2014


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



More information about the tor-talk mailing list