fprintf to stderr crash programs

This is a discussion on fprintf to stderr crash programs within the Windows Programming forums, part of the Platform Specific Boards category; Hi, I have a C program that is compiled within Visual Studio. The C program contains a parent process and ...

  1. #1
    Registered User
    Join Date
    Apr 2005
    Posts
    3

    fprintf to stderr crash programs

    Hi,
    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.


    Thanks,
    Jennifer

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,485
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Apr 2005
    Posts
    3
    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, 01: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, 03:19 PM
  4. program not working...please look at this
    By JOlszewski in forum C Programming
    Replies: 3
    Last Post: 01-30-2006, 09:33 PM
  5. POSIX/DOS programs?
    By nickname_changed in forum C++ Programming
    Replies: 1
    Last Post: 02-28-2003, 04:42 AM

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