LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 10-18-2020, 11:55 AM   #1
MasterZ80
LQ Newbie
 
Registered: Oct 2020
Posts: 5

Rep: Reputation: Disabled
tor.pid file missing after reboot on Slackware Current


Hi folks,

I'm wondering if anyone is facing this. I compile Tor from Slackbuilds.org on Slackware current, Tor works fine until reboot the system, the PID file always disappears (and the /var/run/tor directory too). Trying to launch rundeck I see the following error on /var/log/tor/tor.log:

Code:
Oct 17 12:20:52.000 [warn] Unable to open "/var/run/tor/tor.pid" for writing: No such file or directory
Oct 17 12:20:52.000 [err] Unable to write PIDFile "/var/run/tor/tor.pid"
So, as a dirty workaround, I created the file before start Tor on rc.local init script "manually" in the following way:

Code:
# Tor.
if [ -x /etc/rc.d/rc.tor ]; then
	# slackware current pid workaround.
	if [ ! -f /var/run/tor/tor.pid ]; then
		mkdir /var/run/tor
		touch /var/run/tor/tor.pid
		chown -R tor:tor /var/run/tor/
	fi

	# now start tor
    /etc/rc.d/rc.tor start
fi
This works OK but it's just a workaround, would be ideal that works without this manual file creation. Any thoughts about this?

Thanks in advance.
 
Old 10-18-2020, 02:41 PM   #2
mumahendras3
Member
 
Registered: Feb 2018
Location: Indonesia
Distribution: Slackware-current + s6 + s6-rc + s6-linux-init (github.com/mumahendras3/sl6ckware)
Posts: 125

Rep: Reputation: Disabled
I don't use Tor, but I don't think you actually need to create the tor.pid file. You probably only need to create the /var/run/tor directory so that Tor can write its pid file inside /var/run/tor directory. Also, It's normal that the pid file is gone when you reboot since it's only used to stop Tor process by using its PID written inside that pid file. I think the Tor slackbuild mantainer need to add a mkdir command inside the rc.tor script before starting the main Tor process.
 
Old 10-18-2020, 04:32 PM   #3
PROBLEMCHYLD
Senior Member
 
Registered: Apr 2015
Posts: 1,201

Rep: Reputation: Disabled
You have to add it in your torrc file like

PidFile /var/run/tor/tor.pid
 
Old 10-18-2020, 05:22 PM   #4
MasterZ80
LQ Newbie
 
Registered: Oct 2020
Posts: 5

Original Poster
Rep: Reputation: Disabled
Thanks for the help! Another way is to add the following code on the tor_start() function (on /etc/rc.d/rc.tor file):

Code:
mkdir /var/run/tor/
chown tor:tor /var/run/tor
And now tor can create the PID file with:

Code:
/usr/bin/tor -f /etc/tor/torrc
It's a workaround too but looks like more elegant than add all proccess on the rc.local script.
 
Old 10-19-2020, 06:02 AM   #5
chrisretusn
Senior Member
 
Registered: Dec 2005
Location: Philippines
Distribution: Slackware64-current
Posts: 2,969

Rep: Reputation: 1548Reputation: 1548Reputation: 1548Reputation: 1548Reputation: 1548Reputation: 1548Reputation: 1548Reputation: 1548Reputation: 1548Reputation: 1548Reputation: 1548
Quote:
Originally Posted by MasterZ80 View Post
Thanks for the help! Another way is to add the following code on the tor_start()
When Slackware put /run on tmpfs, this is what I did. Bold is the addition.
Code:
tor_start() {
  PID=$(/bin/cat $PIDFILE 2>/dev/null)
  if [ -n "$PID" ]; then
    echo "Tor is already running. PID: $PID"
  else
    # If there is a PIDFILE, tor acts like it starts, but doesn't. 
    if [ -f "$PIDFILE" ]; then
      rm -f $PIDFILE
    fi
    if [ ! -d /var/run/tor ]; then
      mkdir -p /var/run/tor
      chown tor:tor /var/run/tor
    fi
    echo "Starting tor:  /usr/sbin/tor"
    /usr/sbin/tor
  fi
}
Quote:
It's a workaround too but looks like more elegant than add all proccess on the rc.local script.
I don't view this as a workaround. It how it should be handled in my view. Also you do not need to create the PID file.

Edit: I made this change to my local build for tor, not directly to the installed /etc/rc.d/rc.tor file.

Last edited by chrisretusn; 10-19-2020 at 06:08 AM.
 
Old 10-19-2020, 06:36 AM   #6
MasterZ80
LQ Newbie
 
Registered: Oct 2020
Posts: 5

Original Poster
Rep: Reputation: Disabled
Hi chrisretusn, it seems logic. The original tor_start() function on rc.tor file hosted on Slackbuilds.org have this look:

Code:
tor_start() {
  if [ -n "$MAX_FILEDESCRIPTORS" ]; then
    echo -n "Raising maximum number of filedescriptors (ulimit -n) to $MAX_FILEDESCRIPTORS"
    if ulimit -n "$MAX_FILEDESCRIPTORS" ; then
      echo "..."
    else
      echo ": FAILED."
    fi
  fi
  echo "Starting Tor..."
  /usr/bin/tor
}
I'll improve the code with your suggestion. Thanks a lot.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Tor does no longer start automatically after update to tor 0.2.7.6 Michael Uplawski Linux - Software 6 08-20-2017 11:15 AM
reading pid from pid file in C language shifter Programming 1 05-14-2008 10:49 AM
ERROR: Couldn't write pid to pid file lawrencegoodman Linux - Newbie 2 02-13-2004 08:05 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 01:46 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration