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:
> > On Tue, Feb 04, 2025 at 09:12:18AM +0100, Samuel Thibault wrote:
> > > Only out_io and err_io are supposed to be readable. Or did they mean
> > > from the point of view of the executed process. Again, it means check
> > > what exactly happens to end up with "all readable fds are closed"
> > 
> > Try to keep the consistency of the mail list thread so I reply to this
> > email.
> 
> Threads don't have to be linear :) On the contrary, it's useful to
> answer the mail that you want to answer to, to keep context together.
> The other small piece of thread will just remain in its own corner.

OK
> 
> > 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

Zhaoming


Reply via email to