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

Rob Browning <[email protected]>
Newsgroups gmane.lisp.guile.devel
Message-ID <[email protected]>
Rob Browning <[email protected]> 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)                                                 \
      {                                                      \
        scm_i_pthread_mutex_t *lock___ = (lock);             \
        scm_i_pthread_mutex_lock (lock___);                  \
        errno = 0;                                           \
        { body; }                                            \
        int err___ = errno;                                  \
        scm_i_pthread_mutex_unlock (lock___);                \
        if (err___ != EINTR)                                 \
          break;                                             \
        scm_async_tick ();                                   \
      }

Though a good, shorter name would be nice.  Then we'd have:

  #ifdef HAVE_TTYNAME_R
    SCM_SYSCALL (err = ttyname_r (fd, name, TTY_NAME_MAX));
  #else // HAVE_TTYNAME
    char *global_name = 0;
    SCM_LOCKED_SYSCALL(&scm_i_misc_mutex, global_name = ttyname (fd));
    if (global_name)
      strcpy(name, global_name);
  #endif // HAVE_TTYNAME
  
-- 
Rob Browning
rlb @defaultvalue.org and @debian.org
GPG as of 2011-07-10 E6A9 DA3C C9FD 1FF8 C676 D2C4 C0F0 39E9 ED1B 597A
GPG as of 2002-11-03 14DD 432F AE39 534D B592 F9A0 25C8 D377 8C7E 73A4
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.