dnkl/foot
41
2.0k
Fork
You've already forked foot
243

Spawning new terminal with foot_exe from parent instance #2260

Open
skleinxyz wants to merge 1 commit from skleinxyz/foot:sklein-spawning-new-terminal-with-foot_exe-from-parent-instance into master
pull from: skleinxyz/foot:sklein-spawning-new-terminal-with-foot_exe-from-parent-instance
merge into: dnkl:master
dnkl:master
dnkl:osc-5522
dnkl:sixel-heap-buffer-overflow
dnkl:releases/1.27
dnkl:releases/1.26
dnkl:releases/1.25
dnkl:releases/1.24
dnkl:multi-cursor
dnkl:releases/1.23
dnkl:pixman-16f-2
dnkl:releases/1.22
dnkl:releases/1.21
dnkl:releases/1.20
dnkl:releases/1.19
dnkl:releases/1.18
dnkl:releases/1.17
dnkl:releases/1.16
dnkl:releases/1.15
dnkl:releases/1.14
dnkl:releases/1.13
dnkl:releases/1.12
dnkl:releases/1.11
dnkl:releases/1.10
dnkl:releases/1.9
dnkl:releases/1.8
dnkl:releases/1.7
dnkl:releases/1.6
dnkl:releases/1.5
dnkl:releases/1.4
dnkl:releases/1.3
dnkl:releases/1.2
dnkl:releases/1.1
dnkl:releases/1.0
Contributor
Copy link

While I was developing the Pull Request https://codeberg.org/dnkl/foot/pulls/2259, I noticed that here the term_spawn_new function launches foot by default found in PATH and not the real executable that launched the first instance of foot.

In this commit, I identify the full path of the foot binary by reading the content of /proc/self/exe. Is this method suitable?

Signed-off-by: Stéphane Klein contact@stephane-klein.info

While I was developing the Pull Request <https://codeberg.org/dnkl/foot/pulls/2259>, I noticed that [here](https://codeberg.org/dnkl/foot/src/commit/b78cc92322dd2ae431dbbb70bc681b4d603d844d/terminal.c#L3805) the `term_spawn_new` function launches `foot` by default found in `PATH` and not the real executable that launched the first instance of `foot`. In this commit, I identify the full path of the foot binary by reading the content of `/proc/self/exe`. Is this method suitable? Signed-off-by: Stéphane Klein <contact@stephane-klein.info>
Spawning new terminal with foot_exe from parent instance
Some checks are pending
ci/woodpecker/pr/woodpecker Pipeline is pending approval
builds.sr.ht/freebsd-x64 Job completed
55f743fe4e
Signed-off-by: Stéphane Klein <contact@stephane-klein.info>
Owner
Copy link

In this commit, I identify the full path of the foot binary by reading the content of /proc/self/exe. Is this method suitable?

For linux, yes, but I don't think that'll work for FreeBSD. @jbeich do you have any suggestions?

> In this commit, I identify the full path of the foot binary by reading the content of /proc/self/exe. Is this method suitable? For linux, yes, but I don't think that'll work for FreeBSD. @jbeich do you have any suggestions?
Contributor
Copy link

/proc/self/exe can be implemented via KERN_PROC_PATHNAME (sysctl) supported on DragonFly, FreeBSD, NetBSD (slightly different MIB order).

Some examples:

OpenBSD lacks KERN_PROC_PATHNAME, so hardcode absolute path like
/usr/local/bin/foot where /usr/local can be derived from Meson's
get_option('prefix') and foot via getprogname().

`/proc/self/exe` can be implemented via `KERN_PROC_PATHNAME` (sysctl) supported on DragonFly, FreeBSD, NetBSD (slightly different MIB order). Some examples: - https://github.com/KhronosGroup/Vulkan-Loader/commit/b35527922c54 - https://github.com/hyprwm/Hyprland/commit/4e628d4bd2a9 OpenBSD lacks `KERN_PROC_PATHNAME`, so hardcode absolute path like `/usr/local/bin/foot` where `/usr/local` can be derived from Meson's `get_option('prefix')` and `foot` via `getprogname()`.
dnkl left a comment
Copy link

@skleinxyz if you don't feel like finishing the BSD part, we could merge what you've done so far. You'd have to protect the new code inside:

#if defined(__linux__)
...
#endif

and then fallback to foot (i.e. the old behavior) on all other platforms. In fact, it might be a good idea to do that on linux too, if we for whatever reason fail to read /proc/self/exe.

@skleinxyz if you don't feel like finishing the BSD part, we could merge what you've done so far. You'd have to protect the new code inside: ```c #if defined(__linux__) ... #endif ``` and then fallback to `foot` (i.e. the old behavior) on all other platforms. In fact, it might be a good idea to do that on linux too, if we for whatever reason fail to read `/proc/self/exe`.
Some checks are pending
ci/woodpecker/pr/woodpecker Pipeline is pending approval
builds.sr.ht/freebsd-x64 Job completed
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u sklein-spawning-new-terminal-with-foot_exe-from-parent-instance:skleinxyz-sklein-spawning-new-terminal-with-foot_exe-from-parent-instance
git switch skleinxyz-sklein-spawning-new-terminal-with-foot_exe-from-parent-instance

Merge

Merge the changes and update on Forgejo.
git switch master
git merge --no-ff skleinxyz-sklein-spawning-new-terminal-with-foot_exe-from-parent-instance
git switch skleinxyz-sklein-spawning-new-terminal-with-foot_exe-from-parent-instance
git rebase master
git switch master
git merge --ff-only skleinxyz-sklein-spawning-new-terminal-with-foot_exe-from-parent-instance
git switch skleinxyz-sklein-spawning-new-terminal-with-foot_exe-from-parent-instance
git rebase master
git switch master
git merge --no-ff skleinxyz-sklein-spawning-new-terminal-with-foot_exe-from-parent-instance
git switch master
git merge --squash skleinxyz-sklein-spawning-new-terminal-with-foot_exe-from-parent-instance
git switch master
git merge --ff-only skleinxyz-sklein-spawning-new-terminal-with-foot_exe-from-parent-instance
git switch master
git merge skleinxyz-sklein-spawning-new-terminal-with-foot_exe-from-parent-instance
git push origin master
Sign in to join this conversation.
No reviewers
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
dnkl/foot!2260
Reference in a new issue
dnkl/foot
No description provided.
Delete branch "skleinxyz/foot:sklein-spawning-new-terminal-with-foot_exe-from-parent-instance"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?