Maxime Devos <maximede...@telenet.be> 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 confident POSIX requires TTY_NAME_MAX to include // the trailing null. Assumes TTY_NAME_MAX < SIZE_MAX. int err = 0; char name[TTY_NAME_MAX + 1]; #ifdef HAVE_TTYNAME_R SCM_SYSCALL (err = ttyname_r (fd, name, TTY_NAME_MAX)); #else // HAVE_TTYNAME char *global_name; 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_name || err != EINTR) break; scm_async_tick (); } strcpy(name, global_name); #endif // HAVE_TTYNAME if (err) return scm_from_int(err); else return scm_from_locale_string (name); } Thanks -- 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