bugGNU Screen - Bugs: bug #65653, [PATCH] Add an option to create...

 
 

bug #65653: [PATCH] Add an option to create new window in current foreground process's cwd

Submitter:  Hayato Hiramatsu <hayatosv>
Submitted:  Sun 28 Apr 2024 11:25:09 AM UTC
   
 
Category:  Feature Request Severity:  3 - Normal
Priority:  * 5 - Normal Status:  Wont Fix
Privacy:  Public Assigned to:  None
Open/Closed:  Closed Release:  None
Fixed Release:  None Planned Release:  None
Work Required:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Thu 15 May 2025 01:26:13 PM UTC, comment #6: 

Sorry Hayato, but I don't think this patch will be added. You're playing with filesystems, and that's not a good idea.
Second, you specified Linux and NetBSD, OpenBSD, FreeBSD. Okay, what about other systems?

If you want to add some new functionality, you'll have to use C lib, not play with files in /proc.

Feel free to play with screen's sources, but try to get everything by using standard C lib functions.

I will close this report.

Alexander Naumov <anaumov>
Group administrator
Sun 11 May 2025 07:25:27 AM UTC, comment #5: 

I'm sorry for sending multiple revisions.
I added NetBSD support in the new v5 patch, tested on NetBSD 10.1.

NetBSD supports /proc/PID/cwd like Linux and no further branching was needed.

(file #57213)

Hayato Hiramatsu <hayatosv>
Mon 05 May 2025 09:57:06 AM UTC, comment #4: 

Thank you for looking into this.

I tested on OpenBSD and additionally FreeBSD.  The previous patch needed to be modified to support them and
I updated the patch.

I tested the new v4 patch with Linux, OpenBSD 7.7, and FreeBSD 14.2
and on all three OSes it is working.

On OpenBSD and FreeBSD, sysctl can be used to retrieve the cwd of the process.
Because preprocessor conditionals were added and the logic got longer, I extracted it as a function into tty.c.

(file #57193)

Hayato Hiramatsu <hayatosv>
Thu 01 May 2025 12:22:11 PM UTC, comment #3: 

Thank you Hayato for this patch.
Can you test it on OpenBSD please?

Alexander Naumov <anaumov>
Group administrator
Sat 08 Mar 2025 03:11:05 AM UTC, comment #2: 

Hi,

I fixed a bug in the previous patch.

Please consider including this.

(file #56981)

Hayato Hiramatsu <hayatosv>
Sat 01 Mar 2025 01:50:55 PM UTC, comment #1: 

Hi,

I attached the slightly updated patch v2, which removes preprocessor OS guards like the other usage of procfs.

I tested on screen-5.0.0.
It's working as intended on 5.0.0.

(file #56961)

Hayato Hiramatsu <hayatosv>
Sun 28 Apr 2024 11:25:09 AM UTC, original submission:  

Hello,

I wrote a patch to add an option to create a new window in current foreground process's current working directory (cwd).
Please review it!

This options is very useful when you want to do other things in the same directory
after you already started a long-running process.  Or, when the process is taking longer than you thought.

Also useful when you are using programs which manage their cwds. (like ftp client or editors)


This patch adds an option "-C" to :screen command.
":screen -C" calls tcgetpgrp and reads /proc/PID/cwd to get cwd of current foreground process.

I tried to achieve this by other means but, it turned out screen's support is necessary:
- If I add PROMPT_COMMAND or create alias for cd command in shell to keep track of cwd,
  child processes can chdir to any directory.
  So, suspending foreground process to back to shell is not an option either.

- To get cwd of current foreground process /proc/PID/cwd can be used in Linux, but
  no existing commands including :exec can get pids.
  Because :exec creates new process with new pts, we cannot find out which process was in foreground just before :exec.


Thank you.

Hayato Hiramatsu <hayatosv>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #57213:  new_windows_in_cwd_v5.patch added by hayatosv (2KiB - application/octet-stream)
file #57193:  new_windows_in_cwd_v4.patch added by hayatosv (2KiB - application/octet-stream)
file #56981:  new_windows_in_cwd_v3.patch added by hayatosv (909B - application/octet-stream)
file #56961:  new_windows_in_cwd_v2.patch added by hayatosv (804B - application/octet-stream)
file #55987:  new_windows_in_cwd_v1.patch added by hayatosv (967B - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by anaumov (Posted a comment)
  • -email is unavailable- added by hayatosv (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2025-05-15 anaumov StatusNone Wont Fix
        Open/ClosedOpen Closed
    2025-05-11 hayatosv Attached File- Added new_windows_in_cwd_v5.patch, #57213
    2025-05-05 hayatosv Attached File- Added new_windows_in_cwd_v4.patch, #57193
    2025-03-08 hayatosv Attached File- Added new_windows_in_cwd_v3.patch, #56981
    2025-03-01 hayatosv Attached File- Added new_windows_in_cwd_v2.patch, #56961
    2024-04-28 hayatosv Attached File- Added new_windows_in_cwd_v1.patch, #55987

    Back to the top

    Powered by Savane 3.15-e6e5.
    Corresponding source code