Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exiftool perl process keeps running after a critical error in the python process (SEGFAULT or kill -9) #1583

Open
garz75 opened this issue Jun 17, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@garz75
Copy link

garz75 commented Jun 17, 2024

Describe the bug

When the main exiftool python process is killed abruptly (SEGFAULT or kill -9), the perl process started for exiftool keeps running (see screenshots). I am not sure if it is an exiftool bug or an osxphotos bug: when the osxphotos process is killed, the perl process should receive a signal (SIGPIPE, if I remember my college Unix courses correctly), and exit by itself...

To Reproduce

  1. Run osxphotos export with the --exiftool argument (see below the full command line used if needed)
  2. kill -9 {osxphotos pid}
  3. a ps shows a perl process still running (see screenshot)

Expected behavior

The perl process should exit or be killed

Screenshots

Command line used:

$ osxphotos export osxphotos --retry 3 --update --report export_all_report-`date +%Y-%m-%d-%H%M%S`.json \
   --cleanup --query-eval "list(filter(re.compile(r'^(19|20)').match, [item for sublist in [a.folder_names for a in photo.album_info] for item in sublist]))"  \
   --convert-to-jpeg --jpeg-quality 0.95 --directory "{folder_album,NoAlbum}"  --person-keyword --keyword-template "{label}" \
   --skip-original-if-edited --exiftool --filename "{created.strftime,%Y-%m-%d-%H%M%S}-{exiftool:EXIF:SubSecTimeOriginal,000}" \
   --jpeg-ext jpg --description-template "{descr}{detected_text? - {detected_text},}" --timestamp -V -V

Lingering perl processes after 3 SEGFAULTS and one kill -9:

$ ps auxw | grep perl
fgarzon          82103   0.1  0.0 411755632    992 s000  S    Sun07PM  14:53.28 /usr/bin/perl5.30 -w /opt/homebrew/bin/exiftool -stay_open True -api largefilesupport=1 -@ - -common_args -n -P -G -E
fgarzon          84911   0.1  0.0 411780896    976 s000  S    Sun09PM  12:28.47 /usr/bin/perl5.30 -w /opt/homebrew/bin/exiftool -stay_open True -api largefilesupport=1 -@ - -common_args -n -P -G -E
fgarzon          42827   0.1  0.8 411899840 131040 s000  S    10:09PM   6:57.88 /usr/bin/perl5.34 -w /opt/homebrew/bin/exiftool -stay_open True -api largefilesupport=1 -@ - -common_args -n -P -G -E
fgarzon          79241   0.1  0.0 411771136    992 s000  S    Sun06PM  14:10.09 /usr/bin/perl5.30 -w /opt/homebrew/bin/exiftool -stay_open True -api largefilesupport=1 -@ - -common_args -n -P -G -E
fgarzon          43708   0.0  0.0 410592976   1328 s003  S+   10:31PM   0:00.00 grep perl

Note: The segfaults I mention were due to a faulty python installation, it is not a bug in osxphotos. Upgrading python with homebrew fixed the issue....

Desktop (please complete the following information):

osxphotos --version
osxphotos, version 0.68.2
Python 3.12.4 (main, Jun  6 2024, 18:26:44) [Clang 15.0.0 (clang-1500.3.9.4)]
macOS 14.5.0, arm64
@RhetTbull
Copy link
Owner

I'm not sure if this is something I can fix but will take a look at the python subprocess module to see if I'm missing something. When exiftool is first called, a persistent exiftool process is started in a subprocess and the osxphotos python code then communicates with this process to run the exiftool commands. This prevents having to start a new exiftool process for every photo. There is tear-down code that will kill any lingering exiftool processes at shutdown but of course, this doesn't get called if you kill the python process or it segfaults.

@RhetTbull RhetTbull added the bug Something isn't working label Jun 17, 2024
@RhetTbull
Copy link
Owner

@all-contributors please add @garz75 for bug

Copy link
Contributor

@RhetTbull

I've put up a pull request to add @garz75! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants