Thread: Flushing of data is not proper.

  1. #1
    Registered User
    Join Date
    Dec 2005
    Posts
    136

    Question Flushing of data is not proper.

    Hi all,

    I am Going through a problem on files.
    Environment of problem is, I have opened some files for logging.
    Now when program is going through load testing then it flush Log data in various file(which i have opened in my program, and one file is opened by Apache as error_log).

    But sometime it happenes, My own file data get flushed into error_log of apache.

    Can anybody tell me why this is so?
    S_ccess is waiting for u. Go Ahead, put u there.

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    So let me get this straight...you have error_log opened, your write data to it and flush it, and you're surprised that it's showing up in the file?

    Linux doesn't have inherent file sharing prohibitions like Windows does if that's what you're confused about. Linux will let 2 different programs write to the same file without complaining which might lead to weird results.
    If you understand what you're doing, you're not learning anything.

  3. #3
    Registered User
    Join Date
    Dec 2005
    Posts
    136

    Exclamation

    Quote Originally Posted by itsme86
    So let me get this straight...you have error_log opened, your write data to it and flush it, and you're surprised that it's showing up in the file?

    Linux doesn't have inherent file sharing prohibitions like Windows does if that's what you're confused about. Linux will let 2 different programs write to the same file without complaining which might lead to weird results.
    Thats right that two different programs can write in same file. But tell me is this possible that two different file descriptor pointing to two different file write data into one of them only.
    S_ccess is waiting for u. Go Ahead, put u there.

  4. #4
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    We'd have to see your code to see what's wrong.
    If you understand what you're doing, you're not learning anything.

  5. #5
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    I don't think anything's wrong; I think the OP wants to know why two programs can write to the same file without bad results.

    If you're trying to prevent that, you might try opening the file as exclusive (not with fopen; maybe with open).
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  6. #6
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    is this possible that two different file descriptor pointing to two different file write data into one of them only.
    That sounds more to me like he's trying to write to 2 different files, but all of the data is going into one of them.
    If you understand what you're doing, you're not learning anything.

  7. #7
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Yeah, you're right. But that doesn't make much sense, unless one of the files is a link to the other. Or one of the files is one of the standard streams, and it's being redirected.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. singly linked circular list
    By DarkDot in forum C++ Programming
    Replies: 0
    Last Post: 04-24-2007, 08:55 PM
  2. Binary Tree, couple questions
    By scoobasean in forum C Programming
    Replies: 3
    Last Post: 03-12-2005, 09:09 PM
  3. Templated Binary Tree... dear god...
    By Nakeerb in forum C++ Programming
    Replies: 15
    Last Post: 01-17-2003, 02:24 AM
  4. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM
  5. Post programs
    By GaPe in forum C# Programming
    Replies: 8
    Last Post: 05-12-2002, 11:07 AM