Thread: STDIN stdout

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    19

    Unhappy STDIN stdout

    maybe someone can help me, I am writting a command line interface for an embedded device... kind of like a user shell, it just reads user input parses it, and spits back some output.

    here is my problem, this CLI, needs to run over a serial port, a TCP socket, and a standard linux terminal trasparently... so instead of using send and recv, I am using read and write, which work great for TCP, and serial port, but when it comes to doing something like this on linux

    read( 1, buff, sizeof(buff ));

    I always get core dump.

    does anyone know does linux store stdin, and stdout, as file descriptors ( not pointers )in global varibles???

    thanks
    ~good monkeys, Excelent typewritters!...

  2. #2
    Registered User alex's Avatar
    Join Date
    Sep 2001
    Posts
    132
    I guess you could use fileno(stdin).

    alex

  3. #3
    Im back! shaik786's Avatar
    Join Date
    Jun 2002
    Location
    Bangalore, India
    Posts
    345
    >does anyone know does linux store stdin, and stdout, as file descriptors ( not pointers )in global varibles???
    File descriptor of 'stdin' is 0 (not 1) and of 'stdout' is 1 (and ofcourse, 2 is the 'stderr'). You are trying to read from the output stream, which is incorrect. Change it to:
    read(0, buff, sizeof(buff));

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  2. Replies: 2
    Last Post: 07-12-2008, 12:00 PM
  3. Redirecting STDOUT to STDIN of a child process
    By 0xception in forum Linux Programming
    Replies: 4
    Last Post: 09-13-2005, 11:58 PM
  4. Problems with switch()
    By duvernais28 in forum C Programming
    Replies: 13
    Last Post: 01-28-2005, 10:42 AM
  5. What data type are stdout and stdin?
    By KwikDrawMcGraw in forum C Programming
    Replies: 1
    Last Post: 07-16-2002, 01:34 PM