RE: [PATCH 1/1] fport_print: handle ttyname ENODEV

2025-01-21 Thread Rob Browning
Rob Browning writes: > if (err___ != EINTR) \ > break; \ Rather: if (err___ != EINTR) \ {

RE: [PATCH 1/1] fport_print: handle ttyname ENODEV

2025-01-21 Thread Rob Browning
Rob Browning writes: > If I get time, I might poke around a bit and see if the thing we've > attempted to fix here might be more widespread. I suppose something like this might serve as a generalization: #define SCM_LOCKED_SYSCALL(lock, body) \ while(1)

RE: [PATCH 1/1] fport_print: handle ttyname ENODEV

2025-01-21 Thread Rob Browning
Maxime Devos writes: > That’s it. > > I would add a comment “// we don’t use SCM_SYSCALL, so we can keep the > async tick outside the lock” (or worded differently ofc). Plausible, though as a result of this I'm now a bit wary of SCM_SYSCALL. If I get time, I might poke around a bit and see if th

RE: [PATCH 1/1] fport_print: handle ttyname ENODEV

2025-01-21 Thread Maxime Devos
> It’s simply the case that SCM_SYSCALL is slightly the wrong tool here, > so a slight variant is needed. >Good point. How about this: […] That’s it. I would add a comment “// we don’t use SCM_SYSCALL, so we can keep the async tick outside the lock” (or worded differently ofc). Best regards,

RE: [PATCH 1/1] fport_print: handle ttyname ENODEV

2025-01-21 Thread Rob Browning
Rob Browning writes: > while(1) > { > // ttyname() may use a shared global buffer > scm_i_pthread_mutex_lock (&scm_i_misc_mutex); > global_name = ttyname (fd); > err = errno; > scm_i_pthread_mutex_unlock (&scm_i_misc_mutex); > if (global_n

RE: [PATCH 1/1] fport_print: handle ttyname ENODEV

2025-01-21 Thread Rob Browning
Maxime Devos writes: > It’s simply the case that SCM_SYSCALL is slightly the wrong tool here, > so a slight variant is needed. Good point. How about this: SCM scm_i_c_ttyname (int fd) { // Return the string ttyname or the integer errno. We can remove the // + 1 if we become conf

RE: [PATCH 1/1] fport_print: handle ttyname ENODEV

2025-01-21 Thread Maxime Devos
>Assuming you don't see anything amiss, perhaps I'll include this: [patch] While I’m not familiar with how ‘dynwind’ is to be used from C, if the dynwind means what I’d expect it to mean, then this would Ensure the mutex is unlocked. But, it has another problem: deadlocking, for some uses of asy

RE: [PATCH 1/1] fport_print: handle ttyname ENODEV

2025-01-21 Thread Maxime Devos
>> • EINTR is not in the list of errors mentioned by POSIX (so would never >> happen on correct POSIX systems) >I'm not sure this matters for a Z release. Current Guile will handle EINTR for ttyname() right now (the way it does for everything else), and changing it might break any systems that,

RE: [PATCH 1/1] fport_print: handle ttyname ENODEV

2025-01-21 Thread Rob Browning
Maxime Devos writes: > But since the new is based on the old … Right. I'm most concerned with the changes being made relative to what we had. > • EINTR is not in the list of errors mentioned by POSIX (so would never > happen on correct POSIX systems) I'm not sure this matters for a Z release

RE: [PATCH 1/1] fport_print: handle ttyname ENODEV

2025-01-21 Thread Maxime Devos
>>[…] >It's also used in fports.c in the patch -- we need the helper so we can get the errno in order to handle ENODEV in fport_print. Ok, I think I assumed everything was being done in one file and glossed over the file names. >> Also, the locking is like... >OK, so you're saying that the _exi

RE: [PATCH 1/1] fport_print: handle ttyname ENODEV

2025-01-21 Thread Rob Browning
Rob Browning writes: > I'll look a bit more closely at your locking concern. Unless there's > something else going on, I completely agree that we don't want to exit > without releasing the lock. Assuming you don't see anything amiss, perhaps I'll include this: diff --git a/libguile/posix.c b/l

RE: [PATCH 1/1] fport_print: handle ttyname ENODEV

2025-01-21 Thread Rob Browning
Regarding the EINTR, SCM_SYSCALL redirects to comments in scm_syserror which suggest to me that this may be a known issue: https://git.savannah.gnu.org/cgit/guile.git/tree/libguile/error.c?h=v3.0.10&id=b2cc237a02dcb13625885e76df28bc254a522100#n135 If so, then I'm inclined to preserve the exi

RE: [PATCH 1/1] fport_print: handle ttyname ENODEV

2025-01-21 Thread Rob Browning
Maxime Devos writes: > I don’t think the ‘#define FUNC_NAME "scm_i_c_ttyname"’ is actually > doing something for scm_i_ttyname, given the absence of SCM_SYSERROR. Ahh, thanks. With the rework, I don't need that anymore. > Since the internal function is only used in the same file as which it >

RE: [PATCH 1/1] fport_print: handle ttyname ENODEV

2025-01-21 Thread Maxime Devos
>+ // Not necessary if ttyname() must also respect TTY_NAME_MAX. >+ // POSIX ttyname description isn't completely clear. Not necessary -> not certain. I don’t think the ‘#define FUNC_NAME "scm_i_c_ttyname"’ is actually doing something for scm_i_ttyname, given the absence of SCM_SYSERRO