tactikauan / thcrap-steam-proton-wrapper

A wrapper script for launching the official Touhou games on Steam with patches through Proton on GNU/Linux.
The Unlicense
38 stars 6 forks source link

Make PID-grabbing regex stricter #10

Closed minneyar closed 5 months ago

minneyar commented 5 months ago

On the Steam Deck OLED, the existing regex will match ath11k_wq, the kernel driver for the wireless chipset, and so the script will hang forever waiting for it. Adding \.exe on the end of the regex helps to make sure it only matches Touhou executables.

tactikauan commented 5 months ago

Hi. That's unfortunate. This change will break the vpatch substitution, since we'll end up with two \.exes at the end. Perhaps we can instead add a ^ at the beginning of the grep that grabs TH_PID. Though I can only test this tomorrow.

minneyar commented 5 months ago

Good catch, I didn't test using vpatch. I don't think adding a ^ will work since that's not actually the beginning of the line; the output from /proc/*/stat looks like:

47552 (th17.exe) S 47360 47360 47360 0 -1 4194304 222451 0 1 0 4620 1846 0 0 20 0 27 0 328684859 2330398720 86719 18446744073709551615 2101346304 2101351985 4294821616 0 0 0 0 4096 1790 0 0 0 17 4 0 0 0 0 0 2101358592 2101358672 2127220736 4294829915 4294830130 4294830130 4294852518 0

But I think that removing the explicit \.exe from the following substitution should work, since that's being captured by the regex now.

tactikauan commented 5 months ago

You're right, I missed that. Changing the vpatch substitution like this would also require adding \.exe at the end of 東方紅魔郷, which in turn would break the PID grabbing, since the executable name in /proc/*/stat is trucated to 15 bytes, and that's exactly the size of 東方紅魔郷. What if instead of matching the beginning of the line we match the opening parenthesis?

minneyar commented 5 months ago

Ahh, I see. Yeah, I tested that and it looks like it works for me.

Edit: Well, it works for finding the PID, but I'm not sure that will work in the substitution since it will expect ( at the beginning of the command...

Edit 2: Actually, I realized I could just put the parenthesis inside the argument to grep inside of TH_REGEX, so it should find the right PID but not affect the vpatch substitution at all.

tactikauan commented 5 months ago

Looks good to me. Thanks!