bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: vim testsuite: Test_keep_pty_open


From: Samuel Thibault
Subject: Re: vim testsuite: Test_keep_pty_open
Date: Thu, 6 Feb 2025 10:13:23 +0100

Zhaoming Luo, le jeu. 06 févr. 2025 11:11:42 +0800, a ecrit:
> On Thu, Feb 06, 2025 at 10:54:30AM +0800, Zhaoming Luo wrote:
> > On Thu, Feb 06, 2025 at 02:03:26AM +0100, Samuel Thibault wrote:
> > > Zhaoming Luo, le mer. 05 févr. 2025 10:33:04 +0800, a ecrit:
> > > > Intead I wrote the following program to reproduce the error:
> > > > 
> > > > ```
> > > > #include <stdio.h>
> > > > #include <unistd.h>
> > > > #include <fcntl.h>
> > > > 
> > > > int
> > > > main ()
> > > > {
> > > >     int f;
> > > >     int is_term;
> > > > 
> > > >     f = open ("/dev/ttyp4", 0);
> > > 
> > > Oh, does it really open it with neither O_RDONLY nor WRONLY?
> > > 
> > 
> > Err I forgot to check which system call vim uses to get the file
> > descriptor. My bad. After some investigation, it seems posix_openpt is
> > what vim uses[0]. I supposed open is the only system call that can be
> > used for opening file :-|.
> > 
> > Though I don't know why gdb tells me it uses the implementation in
> > $(glibc)/unix/bsd/getpt.c. Is it expected?
> > 
> > gdb bt:
> > ```
> > #0  __x86.get_pc_thunk.bx () at 
> > ../sysdeps/i386/i686/multiarch/memset-sse2.S:97
> > #1  0x029a1919 in __posix_openpt (oflag=3) at ../sysdeps/unix/bsd/getpt.c:87
> > #2  0x00196325 in mch_openpty (ttyn=0x141946c) at pty.c:194
> > #3  0x00181586 in open_pty (pty_master_fd=0x1419498, 
> > pty_slave_fd=0x1419494, name1=0x20004574, name2=0x20004570) at 
> > os_unix.c:4613
> > #4  0x00182ea6 in mch_job_start (argv=0x20036720, job=0x20004560, 
> > options=0x1419588, is_terminal=0) at os_unix.c:5770
> > #5  0x002facba in job_start (argvars=0x1419d18, argv_arg=0x0, opt_arg=0x0, 
> > term_job=0x0) at job.c:1462
> > ...
> > ```
> > 
> > [0]: https://github.com/vim/vim/blob/master/src/pty.c#L194
> 
> So I tried to open /dev/ttyp4 with O_RDWR | O_NOCTTY. The issue is
> permission denied:
> 
> ```
>   16<--34(pid2144)->dir_lookup ("dev/ttyp4" 3 0) = 0x4000000d (Permission 
> denied)
>   31<--28(pid2144)->io_stat_request () = 0 {14 1097 0 0 0 1686195791 0 
> 8397200 1 1001 5 0 0 1738811410 0 1738811410 0 1738811410 0 512 8 0 0 0 
> 132145264 102787024 132262720 132147840 102788912 494940384 132323120 
> 132272016}
>   25<--40(pid2144)->io_write_request ("open() failed\n" -1)open() failed
> ```
> 
> When I run with sudo, it hanged.

I'm not surprised: you're opening another terminal :) You can try to
open your own terminal as returned by the `tty` command.

Samuel



reply via email to

[Prev in Thread] Current Thread [Next in Thread]