I need to be able to get
/sbin/killproc -TERM /root/Desktop/mydaemond
to work, but it is not. This command causes nothing to be logged to /var/log/messages with the syslog() function written inside mydaemond for SIGTERM messages, and mydaemond does not terminate.
However, correctly, if I do “kill <pid of mydaemond>”, then this SIGTERM action is logged to /var/log/messages with the syslog() inside mydaemond, AND mydaemond terminates.
When I run /etc/rc.d/mydaemon start,
mydaemond starts up fine.
But, I am not able to stop mydaemond with killproc.
When I run /etc/rc.d/mydaemon stop,
mydaemond does not stop.
mydaemond is still listed as running in the output of
ps ax | grep mydaemond
If I run
/sbin/killproc -TERM /root/Desktop/mydaemond
echo $?
Then, 7 is displayed and mydaemond is still running.
7 returned for killproc = “Program was not running to receive the specified signal.”
Note: The contents of /var/run/mydaemond.pid is not the correct PID as shown in ps ax | grep mydaemond, probably because of the necessary fork()ing done in mydaemond.
However, killproc is supposed to only need the full path to my executable (/root/Desktop/mydaemond) and not the PID number. Further, these SuSE /etc/rc.d/skeleton based scripts are supposed to work with daemons that should all have fork() in them at least once. Mine does fork()ing twice per the “Advanced Programming in the UNIX Environment, 2nd Edition” book.
First of all, if you are writing your own launch script, it’s possible to write the actual pid into the file with the judicious use of exec. Second, can the program be located via /proc, as the man page says? If not, then it will fail to find the process.
Thanks. I can do that, but since I am fork()ing in the daemon, I will have to write the correct pid to the lock file (/var/run/makehomed.pid) from the child process and not the launch script.
I guess this also implies that the /etc/rc.d/skeleton code is not correct.
Is the full path in there? Also /proc/<pid>/exe has to be a symlink to the actual file, according to the man page you quoted.
Incidentally *.pid is not a lock file. It’s just a file containing the pid. It could be used as a lock file, but lock files normally go into /var/lock whereas pid files go into /var/run
Hi
Two things may be causing problems, one using the Desktop area for
coding (This can cause all sorts of funny results), second being in the
root environment (GUI?)?
Try /root directory, better to develop as a user, test using su -c all
as your user…
Haven’t used strace before. Will try to do that tomorrow.
It’s midnight here. Got to get up early tomorrow.
NOTE: I just tested the binary makehomed and script /etc/rc.d/makehome on openSUSE 11.2, and they work fine.
See below.
HOWEVER, there are differences I made with chmod on /root/makehomed and on /etc/rc.d/makehome, and makehomed is located in /root/ on openSUSE and in /root/Desktop/ on SLES10/OES2. Need to make those differences zero and see if that changes anything.
Obviously you have a very smart killproc program that can detect when questions are being asked about it in forums.opensuse.org. I suggest you maintain its connection to the Internet so that you can continue to provide it with encouragement to behave properly. lol!