Strange persistent Linux processes wasting CPU, can't be killed?

Started by Loren Amelang, December 23, 2024, 12:36:33 AM

Previous topic - Next topic

Loren Amelang

Apologies for the long post - I'm trying to understand this, and the details seem relevant.

On 241216 I installed on Arch Linux:
perl-image-exiftool-13.08-1

Did not add these:
Optional dependencies for perl-image-exiftool
    perl-archive-zip: Support for zip files, including epub
    perl-io-compress-brotli: Support for brotli-compressed metadata

Tried to run it - Mon Dec 16 08:05:58 PM PST 2024

$ exiftool

NAME
    exiftool - Read and write meta information in files
...
    To write or delete metadata, tag values are assigned using
    -*TAG*=[*VALUE*], and/or the -geotag, -csv= or -json= options. To copy
--More--(0%)^[␈ ␈

No idea why it logged "^[" there. Nothing I tried would escape from there. Except... 

^Z
[1]+  Stopped                 exiftool
[loren@Gazp9 ~]$ jobs

[1]+  Stopped                 exiftool
[loren@Gazp9 ~]$ jobs -l

[1]+  3354 Stopped                 exiftool
[loren@Gazp9 ~]$ kill 3354

[1]+  3354 Stopped                 exiftool
[loren@Gazp9 ~]$ fg 3354

bash: fg: 3354: no such job
[loren@Gazp9 ~]$ jobs

[1]+  Stopped                 exiftool
[loren@Gazp9 ~]$ fg 1

exiftool
Terminated


Tried again - same problem, different process number:

[loren@Gazp9 ~]$ kill 4552
[loren@Gazp9 ~]$ fg 1

exiftool
Terminated


With a filenname, it works:
$ exiftool 'Hannah profile.jpg'

ExifTool Version Number         : 12.65
File Name                       : Hannah profile.jpg
Directory                       : .
...


Curious what was running, I searched the whole system:
$ sudo find / -iname exiftool

/usr/lib/perl5/5.40/vendor_perl/auto/Image/ExifTool
/usr/share/perl5/vendor_perl/Image/ExifTool
/usr/share/perl5/site_perl/Image/ExifTool
/usr/bin/vendor_perl/exiftool
/usr/bin/site_perl/exiftool

/home/loren/builds/exiftool
/home/loren/builds/exiftool/Image-ExifTool-12.65/lib/Image/ExifTool
/home/loren/builds/exiftool/Image-ExifTool-12.65/exiftool
/home/loren/builds/exiftool/Image-ExifTool-12.65/blib/lib/auto/Image/ExifTool
/home/loren/builds/exiftool/Image-ExifTool-12.65/blib/lib/Image/ExifTool
/home/loren/builds/exiftool/Image-ExifTool-12.65/blib/arch/auto/Image/ExifTool
/home/loren/builds/exiftool/Image-ExifTool-12.65/blib/script/exiftool
(I forgot I had manually installed a version ages ago...  Maybe that has been removed?)

$ pacman -S -i exiftool
error: package 'exiftool' was not found
$ pacman -Qn | grep exiftool
perl-image-exiftool 13.08-1


I went on to other projects... 


Days later, I noticed something constantly using 12% of my CPU, with the name "more":

Fri Dec 20 07:11:30 PM PST 2024
$ ps aux | grep more
loren       3356 32.1  0.0  21508  8316 pts/0    R    Dec16 1881:34 /usr/bin/more /tmp/mBFuLsRL9d
loren       4554 32.0  0.0  21508  8888 pts/0    R    Dec16 1869:56 /usr/bin/more /tmp/VJYjQ5YMrC

Each process number two digits higher than the ones I'd seen before... 

$ sudo kill 3356

That popped the exiftool help back up!
NAME
    exiftool - Read and write meta information in files

SYNOPSIS
...

Somehow it gave me a prompt back!

$ ps aux | grep more

loren       4554 32.1  0.0  21508  8888 pts/0    R    Dec16 1874:09 /usr/bin/more /tmp/VJYjQ5YMrC
loren     148865 99.9  0.1  21508 16632 pts/0    R    21:39   0:32 more /tmp/mBFuLsRL9d

Had instantly created a new current process with the same screen!

Tried to kill the other one, similar switch:

$ ps aux | grep more

loren     148865 99.9  0.1  21508 16632 pts/0    R    21:39   2:36 more /tmp/mBFuLsRL9d
loren     149004 99.9  0.1  21508 16664 pts/0    R    21:41   0:32 more /tmp/VJYjQ5YMrC

But that started a massive repeating scroll of help pages and eventually just "At EOF" for 31 _million_ lines that nothing seemed able to stop:

    To write or delete metadata, tag values are assigned using
    -*TAG*=[*VALUE*], and/or the -geotag, -csv= or -json= options. To copy
:;0;0t;1H"/tmp/mBFuLsRL9d" [Read only] 2765 lines, 148502 characters NAME
    exiftool - Read and write meta information in files

...

    -*TAG*=[*VALUE*], and/or the -geotag, -csv= or -json= options. To copy"/tmp/mBFuLsRL9d" [Read only] 2765 lines, 148502 characters ;0;0t;1H
Input read error

It then scrolled what I asssume is the whole help file, and then:


    This is free software; you can redistribute it and/or modify it under
    the same terms as Perl itself.

:␈SEE ALSO
    Image::ExifTool(3pm), Image::ExifTool::TagNames(3pm),
    Image::ExifTool::Shortcuts(3pm), Image::ExifTool::Shift.pl

:
At EOF
:
At EOF


for 31 _million_ "EOF" lines before I restarted the computer.


I'm a bit scared to touch it now...  Granted I do not know how to use it properly on Linux. (I had a version in my right click menu in Windows, that just worked with no problems ever.) Maybe I've done something really wrong here?

$ uname -r
6.12.4-arch1-1

Accessed via VNC from an iPad 12.9 5Gen... 

What else might be relevant?

Phil Harvey

Quote from: Loren Amelang on December 23, 2024, 12:36:33 AMTried to run it - Mon Dec 16 08:05:58 PM PST 2024

$ exiftool

Running exiftool with no arguments is equivalent to

$ perldoc exiftool
Quote--More--(0%)^[␈ ␈

No idea why it logged "^[" there. Nothing I tried would escape from there.  Except...

^Z
[1]+  Stopped                 exiftool

Press the "q" key to quit perldoc (same as "man").

QuoteDays later, I noticed something constantly using 12% of my CPU, with the name "more":

It seems that perldoc uses "more" for the paging.  Probably similar to "man".

Quote$ sudo kill 3356

That popped the exiftool help back up!

The original process was still around because you used ^Z to suspend it.  I don't know the mechanics of what happens when you suspend "more", but apparently it involves 2 processes.

Bottom line: You are fighting with perldoc and "more", not ExifTool.

- Phil

Edit: I tried your sequence of events on MacOS, and no extraneous processes were created.

% ps -aelx | grep -E 'exiftool|more|perldoc'
  501  2903  1301     4006   0  31  0  4278296    848 -      S+                  0 ttys001    0:00.00 grep -E exiftool|more|perldoc
% exiftool

Suspended
% ps -aelx | grep -E 'exiftool|more|perldoc'
  501  2904  1301     4006   0  31  0  4309632  17796 -      T                   0 ttys001    0:00.14 perl /Users/phil/bin/exiftool
  501  2905  2904     4006   0  31  0  4318124  13940 -      T                   0 ttys001    0:00.32 /usr/bin/perldoc 
  501  2917  1301     4006   0  31  0  4268056    824 -      S+                  0 ttys001    0:00.00 grep -E exiftool|more|perldoc
% kill 2904
%
[1]    Terminated                    exiftool
% ps -aelx | grep -E 'exiftool|more|perldoc'
  501  2920  1301     4006   0  31  0  4268056    824 -      S+                  0 ttys001    0:00.00 grep -E exiftool|more|perldoc
%
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Loren Amelang

@Phil,

Thanks for the serious reply! Sorry I've been so busy with reality - one of the batteries that run my off-grid home died, and then my generator broke at the beginning of two cloudy weeks... 

I totally believe the problem here was with 'more', not exiftool. I'm pretty sure I tried 'q' at the beginning of the struggle, but maybe it was preceded by some other key pattern that does something unexpected in 'more'. I wish they would put the 'q' clue there for people who don't know what they are interacting with!

QuoteThe original process was still around because you used ^Z to suspend it.  I don't know the mechanics of what happens when you suspend "more", but apparently it involves 2 processes.

I think my problem was trying to suspend or kill exiftool when the problem was with 'more'. I had no idea what was drawing that doc page - 'more', 'less', or I guess 'perldoc'... 

The really strange part was once I saw it was 'more' hogging my CPU. Killing 'more' just recreated another version of it. Maybe perldoc kept recreating them? Maybe if I'd killed perldoc that would have stopped? I have zero experience with perldoc, and had no idea it was involved... 

Maybe you could add a line at the beginning of your help text, revealing that it is being displayed by perldoc and 'more', and that 'q' will close it and 'space' will go to the next page? 


I haven't really searched for this, but is there a quick way to add a right click option in Linux Cinnamon Nemo to run exiftool on the selected file? That was so handy in Windows.

Phil Harvey

Sorry to hear about your generator/battery problems.  I hope you have sorted them all out.

Quote from: Loren Amelang on January 07, 2025, 11:31:11 PMMaybe you could add a line at the beginning of your help text, revealing that it is being displayed by perldoc and 'more'

Before this, I didn't even know the perldoc used "more".

I can't really add this extra line because it would have to be added to the pod documentation, and hence would show up in other inappropriate places (eg. the html and pdf versions of the documentation, and the man pages).

Quoteis there a quick way to add a right click option in Linux Cinnamon Nemo to run exiftool on the selected file?

Sorry, I can't help here.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).