write error with a bad file descriptor

This is a discussion on write error with a bad file descriptor within the C Programming forums, part of the General Programming Boards category; Hi all, I am playing around with redirection and am getting the below error message? can anyone tell me a ...

  1. #1
    Registered User
    Join Date
    Dec 2009
    Posts
    17

    write error with a bad file descriptor

    Hi all,

    I am playing around with redirection and am getting the below error message?

    can anyone tell me a cause for this so i can fix it?

    Code:
    ls: write error: Bad file descriptor
    thanks

    Techevo

  2. #2
    Registered User
    Join Date
    Dec 2009
    Posts
    17
    the command i use to get this was:

    Code:
    ls > file.txt

  3. #3
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,274
    Quote Originally Posted by techevo View Post
    the command i use to get this was:

    Code:
    ls > file.txt
    Are you writing your own shell?

    If "ls > file.txt" is giving you that error from a regular shell, then something is wrong with the shell.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  4. #4
    Registered User
    Join Date
    Feb 2010
    Posts
    57

    Re: write error with a bad file descriptor

    If the error comes in a regular shell then the problem is that your quota or storage memory exceeded.
    If you are trying to create your own shell then the problem may be in your program.

  5. #5
    Registered User
    Join Date
    Apr 2009
    Posts
    66
    Also check the resources using ulimit -a command, I think you are facing some lack of resources issue
    Last edited by Alexander jack; 03-03-2010 at 11:00 PM.

  6. #6
    Registered User
    Join Date
    Dec 2009
    Posts
    17
    Yes i am creating my own shell.

    Thank you for all the suggestions,

    the result of

    Code:
    command -a
    is as follows

    Code:
    core file size          (blocks, -c) 0
    data seg size           (kbytes, -d) unlimited
    scheduling priority             (-e) 20
    file size               (blocks, -f) unlimited
    pending signals                 (-i) 16382
    max locked memory       (kbytes, -l) 64
    max memory size         (kbytes, -m) unlimited
    open files                      (-n) 1024
    pipe size            (512 bytes, -p) 8
    POSIX message queues     (bytes, -q) 819200
    real-time priority              (-r) 0
    stack size              (kbytes, -s) 8192
    cpu time               (seconds, -t) unlimited
    max user processes              (-u) unlimited
    virtual memory          (kbytes, -v) unlimited
    file locks                      (-x) unlimited
    thanks again

    techevo

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,855
    You need to post some of your own code, for your own shell then.

    There's no end of ways you could have screwed up the file descriptors.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File transfer- the file sometimes not full transferred
    By shu_fei86 in forum C# Programming
    Replies: 13
    Last Post: 03-13-2009, 01:44 PM
  2. Replies: 3
    Last Post: 03-04-2005, 02:46 PM
  3. Hmm....help me take a look at this: File Encryptor
    By heljy in forum C Programming
    Replies: 3
    Last Post: 03-23-2002, 10:57 AM
  4. Need a suggestion on a school project..
    By Screwz Luse in forum C Programming
    Replies: 5
    Last Post: 11-27-2001, 02:58 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21