Messages in this thread | | | Date | Wed, 13 Nov 1996 22:46:56 +0100 (MET) | From | Riccardo Facchetti <> | Subject | -ERESTARTSYS and /dev/ttyS1 |
| |
Hello Linuxers,
I have a problem that I can not explain myself (first time I see a -ERESTARTSYS). I think it is related with libc libraries because this is the first time I get this error, and the piece of code I will show you worked fine until now, but I'm not sure when it have started this strange behaviour. I really need to know what's going on (this is the first _real problem_ I have seen since running 2.0.24 kernel).
The system ---------- i486/33 + 8MB RAM + 1 internal TRUST modem on ttyS1 + 1 sound card + 2 IDE interfaces ( 2 HD on the first + (1 HD + 1 CDROM) on the second)
Linux azuth 2.0.24 #1 Sat Nov 2 10:05:25 MET 1996 i486 gcc version 2.7.2.1 ld version 2.7 (with BFD 2.7.0.3) libc.so.5.4.10
The problem ----------- I have a modem on /dev/ttyS1 and I want to open the line and get a file descriptor to talk with my modem.
The solution ------------ ... static void alarm_jump(int sig) { longjmp(not_opened, 1); } ... if (setjmp(not_opened) == 0) { /* * build the modem device filename */ sprintf(buffer, "/dev/%s", device->line);
/* * set up the alarm for jump if timeout */ old_alarm_value = alarm(0); old_alarm = signal(SIGALRM, alarm_jump); alarm(2);
fd = open(buffer, O_RDWR|O_NOCTTY); } /* * Restore the old alarm handler and scheduled timeout */ alarm(0); signal(SIGALRM, old_alarm); alarm(old_alarm_value); if (fd < 0) return (mdmerrno = -EMDMOPEN); ...
The really strange behaviour ---------------------------- Follow the output of strace. Note the -ERESTARTSYS error. According with /usr/include/linux/errno.h: /* Should never be seen by user programs */ __________________________________________________________________________ ... open("/var/spool/uucp/LCK..ttyS1", O_RDONLY) = 3 read(3, " 2017\n", 128) = 11 close(3) = 0 kill(2017, SIGUSR1) = -1 ESRCH (No such process) unlink("/var/spool/uucp/LCK..ttyS1") = 0 open("/var/spool/uucp/LCK..ttyS1", O_WRONLY|O_CREAT|O_EXCL, 03741) = 3 fchmod(3, 0644) = 0 getpid() = 2028 write(3, " 2028\n", 11) = 11 close(3) = 0 alarm(0) = 0 sigaction(SIGALRM, {0x8049230, [], SA_INTERRUPT|SA_NOMASK|SA_ONESHOT}, {SIG_DFL}) = 0 alarm(2) = 0 open("/dev/ttyS1", O_RDWR|O_NOCTTY) = -1 ERESTARTSYS (errno 512) --- SIGALRM (Alarm clock) --- alarm(0) = 0 sigaction(SIGALRM, {SIG_DFL}, {SIG_DFL}) = 0 alarm(0) = 0 write(2, "ldial failed: Can\'t open this l"..., 36ldial failed: Can't open this line. ) = 36 _exit(-1) = ?
Some comments ------------- While receiving that -ERESTARTSYS, I can hear my modem doing sounds like as it is receiving an ATZ command. Seems to me that my program lack some *black magic* initialization that minicom have because I can * ??_reset_?? * (what reset, I just want to open a device file !!!) the modem line (/dev/ttyS1) to its usual behaviour just invoking minicom. Of course I could go to minicom and see where is this *black magic*, and I will do, but this post is mainly to report the -ERESTARTSYS error and of course if someone have a better solution than go to minicom sources, will be welcome :)
Ah of course there may be another reason this problem: I have started to use dcon-0.96 to connect to my ISP. May be dcon do some strange things with /dev/ttyS1, but the real problem is that strange -ERESTARTSYS.
Can a user program (dcon-0.96) set up the /dev/ttyS1 so that after close, another program (my program) can not open() the same line, returning a -ERESTARTSYS and a third program (minicom) can then *reset* it opening and closing the device and giving the second program (my program) a clean /dev/ttyS1 ?
The problem is 100% reproducible.
Ciao, Riccardo.
| |