Thread: fprintf to stderr crash programs

  1. #1
    Registered User
    Join Date
    Apr 2005

    fprintf to stderr crash programs

    I have a C program that is compiled within Visual Studio. The C program contains a parent process and a child process that do some tasks of its own. In the program there are also some fprintf that prints out debug statements to stderr. Here is the problem, when I put fprintf to the program, the program would crash. But when the fprintf statement is commented out, the program executes successfully. I tried to replace fprintf with printf, the
    program also executes without any problem. I then tried to open a file and makes fprintf output to that file, and no problem. I suspect that there is something wrong with stderr, either not open, or just simply not available?

    I know stderr is available on Win32 API, so I even wrote a simple program (without CreateProcess) that has fprintf to stderr, and the program executes without any problem.

    Could stderr not available to child process? Has anyone had seen this problem earlier?

    If this helps,
    I've tried to execute "ferror(stderr);" and the return code is 32.


  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Hard to say, without you post actual code which actually crashes (for you)
    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.

  3. #3
    Registered User
    Join Date
    Apr 2005
    I fixed the problem.
    _DLL needs to be added as part of the preprocessor definition.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Couple errors please help :-D
    By JJJIrish05 in forum C Programming
    Replies: 9
    Last Post: 03-06-2008, 02:54 AM
  2. Alll my opengl programs crash upon startup.
    By indigo0086 in forum Tech Board
    Replies: 2
    Last Post: 06-14-2007, 09:17 AM
  3. help with basic program
    By JOlszewski in forum C Programming
    Replies: 3
    Last Post: 02-01-2006, 04:19 PM
  4. program not working...please look at this
    By JOlszewski in forum C Programming
    Replies: 3
    Last Post: 01-30-2006, 10:33 PM
  5. POSIX/DOS programs?
    By nickname_changed in forum C++ Programming
    Replies: 1
    Last Post: 02-28-2003, 05:42 AM