jobd/taskd: avoid assigning to $0
commit36264b0af908b11d8a07966cb14acdbcdd6625b6
authorKyle J. McKay <mackyle@gmail.com>
Sat, 7 Jan 2017 23:00:59 +0000 (7 15:00 -0800)
committerKyle J. McKay <mackyle@gmail.com>
Sat, 7 Jan 2017 23:00:59 +0000 (7 15:00 -0800)
treec58c699e868bb59cf61747f2eb3bbd8828a89b6e
parent43ebfd41cc29d04443cb4af86fd5f1190d534418
jobd/taskd: avoid assigning to $0

Perl allows assignments to $0 to change the argv[0] value
reported in the environment and ps-type listings.

However, this doesn't always work out so well on some systems
leading to peculiar and unwanted garbage in ps listings.

Originally the only reason the assignment to $0 was done was
to avoid leaving a relative $0 pointing nowhere after doing
chdir("/") which caused pod2usage to fail to work properly.

However, $0 is not actually used for anything after the point
at which the chdir and $0 assignment were done other than
as a default location for pod2usage and to be passed to the
basename function.  But the original $0 is a better choice to
be passed to the basename function in case symbolic links are
involved because basename(realpath($0)) could end up being
different than basename($0).

Therefore remove the assigments to $0 to prevent ps-produced
process printout peculiarities, resolve $0 using realpath and
save the result in a "my" variable before using chdir("/") and
then pass the saved realpath($0) to pod2usage as the -input
argument so it can still find the source file.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
jobd/jobd.pl
taskd/taskd.pl