Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6605051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:14:16+00:00 2026-05-25T19:14:16+00:00

I have a process opening a file in append mode. In this case it

  • 0

I have a process opening a file in append mode. In this case it is a log file. Sample code:

int main(int argc, char **argv) {
    FILE *f;
    f = fopen("log.txt", "a");
    fprintf(f, "log entry line");
    fclose(f);
}

Two questions:

  1. If I have multiple processes appending to the same file, will each log line appear distinctly or can they be interlaced as the processes context switch?
  2. Will this write block if lots of processes require access to the file, therefore causing concurrency problems?

I am considering either doing this in its simplest incarnation or using zeromq to pump log entries over pipes to a log collector.

I did consider syslog but I don’t really want any platform dependencies on the software.

The default platform is Linux for this btw.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:14:17+00:00Added an answer on May 25, 2026 at 7:14 pm

    You’ll certainly have platform dependencies since Windows can’t handle multiple processes appending to the same file.

    Regarding synchronization problems, I think that line-buffered output /should/ save you most of the time, i.e. more than 99.99% of short log lines should be intact according to my short shell-based test, but not every time. Explicit semantics are definitely preferable, and since you won’t be able to write this hack system-independently anyway, I’d recommend a syslog approach.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two process and a shared memory zone, my workflow is like this.
I have a Java process that opens a file using a FileReader. How can
I have following text after reading a file: 06/16/2011 04:01:05 AM : Process Start
I have a large XML data file (>160M) to process, and it seems like
I have a Windows Service that hangs when opening an OLEDB-connection to an Excel-file,
I have a log file that continually logs short lines. I need to develop
I have a scenario where one PHP process is writing a file about 3
I have a windows service that writes out log file entries to an XML
I have Process objects that are monitored from two different views. A Windows.Forms.ListView (actually
I have 1 process that receives incoming connection from port 1000 in 1 linux

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.