"Not a typewriter" error message 
Author Message
 "Not a typewriter" error message

Has anybody encountered this error message when
running a C program? Any clue as to what it might
mean?  (it was generated using 'perror'). Outside
of seeing this, the program seems to give correct
results.


Sun, 12 Oct 1997 03:00:00 GMT  
 "Not a typewriter" error message

Quote:
>Has anybody encountered this error message when
>running a C program? Any clue as to what it might
>mean?  (it was generated using 'perror'). Outside
>of seeing this, the program seems to give correct
>results.

This error message has nothing to do with the C language, it is Unix
specific.  comp.unix.questions is the best place to ask about it (or,
maybe, comp.unix.programmer).

Its meaning is that a terminal specific operation has been attempted on
a file descriptor which was not connected to a terminal.

Dan
--
Dan Pop
CERN, CN Division

Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland



Sun, 12 Oct 1997 03:00:00 GMT  
 "Not a typewriter" error message

Quote:
> > Has anybody encountered this error message when
> > running a C program? Any clue as to what it might
> > mean?  (it was generated using 'perror'). Outside
> > of seeing this, the program seems to give correct
> > results.


Quote:
> This error message has nothing to do with the C language, it is Unix
> specific.  comp.unix.questions is the best place to ask about it (or,
> maybe, comp.unix.programmer).

> Its meaning is that a terminal specific operation has been attempted on
> a file descriptor which was not connected to a terminal.

But in fact, there is a C lesson in this.  The most common reason for
seeing "not a typewriter" emerging from an otherwise correct program
is that you called perror() *when no error indication had been returned*.
The fact that errno is nonzero does *not* mean that there was an error.

See, stdio is commonly implemented so that stdout is fully buffered if
directed to a file, but not if directed to a terminal.  It may need to
test whether other files are directed to a terminal too.  One way to make
that test is to attempt a terminal-specific operation and *see whether
it fails*.  If it fails, it leaves errno set to the value that perror()
displays as "not a typewriter"; the library checks for that, and knows
what to do.  And then leaves the value unchanged.

And that's all right, because as the C standard says (in 7.1.4/4.1.3):

#  The value of errno may be set to nonzero by a library function call
#  whether or not there is an error, provided the use of errno is not
#  documented in the description of the function in the Standard.

In general, you should look at errno only when some library function
that is documented as setting errno on failure has just returned a
failure indication.  Errno tells you *what* failure occurred, but
never *that* failure occurred.

(However, having said that, in practice errno can sometimes have a
meaningful value in it when an error indication was returned, even if
this is not documented.  So it can be a practical thing to call perror()
whenever an error indication is returned.  For example, on this system,
fopen() is not documented as setting errno, and the C standard doesn't
promise that it does either.  But it calls the UNIX function open() to
actually open the file, and that does set errno, so on this system I can
safely use errno after fopen() returns NULL, documentation notwithstanding.
The really important thing is to NOT look at errno when NO error was
indicated.  Also, it's a good idea to set it to zero before a call if
you're going to look at its value afterwards, to prevent old errors
from confusing you.)
--

        "I'm a little worried about the bug-eater," she said.  "We're embedded
        in bugs, have you noticed?"             -- Niven, "The Integral Trees"

This article is in the public domain.



Tue, 14 Oct 1997 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Error message: "Interface not registered"

2. "can not find debug information" message

3. "Data source not found" message

4. Error "free"-ing "malloc"-ed memory

5. "Can not start Print Job!" Message

6. Catching "Not Responding" messages

7. Q: Error message "Multiple rows updated"???

8. "Cannot save file" error message

9. "Cannot save file" error message

10. Troubles with "lvalue missing" error message

11. "Not a typewriter" error? Need help...

12. "Floating point formats not linked" error

 

 
Powered by phpBB® Forum Software