Re: off topic: combined output of concurrent processes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 15Apr2012 02:32, Amadeus W.M. <amadeus84@xxxxxxxxxxx> wrote:
| > | Multiple processes that open the same file for writing each maintain |
| > their own file positions, so they may overwrite the output of another |
| > process, unless the processes all open the file with the "O_APPEND" |
| > option.
| > 
| > This only matters if the processes _independently_ opened the file. So
| > this:
| >   echo AAA >foo &
| >   echo BBB >foo &
| > 
| > pretty much _will_ overwrite each other. But the OP effectively has
| > this:
| >   ( echo AAA &
| >     echo BBB &
| >   ) >foo
| > 
| > Only _one_ open file handle in play. The writes may happen in either
| > order but they will _not_ overwrite each other because there is only one
| > file handle, and thus only one file position pointer.
| > 
| 
| This is a fine point and it does make sense. However, why do I not get 
| all 100 blocks of As, 100 blocks of Bs, etc. The for loop has 100 
| iterations, so there should be 100 lines each. 

I don't know yet. I need to test it out on my own system.

| Also, how would I know I'm overwriting the buffer. The output of each 
| process (the echo in the example) is not 500 bytes but more like 30-40 
| Kb, possibly more, but not Mb.

Sum the expected number of bytes for the file. Examine the file size.
If they differ then either overwriting is happening or the echoes are
not all successful. If the file is VERY small then it is probably
overwriting. But if it is roughtly the expected size then not all the
writes are making it to the file, so echo is writing incomplete data or
not all the echoes run.

BUT:

in another post you write:

  No, I didn't write the code and it's not echo, it's in fact curl.

Oh. You should have said that earlier. Curl will be doing multiple
writes (versus echo which will be doing only one).

  But >>
  instead of > should do, no?

Definitely yes. But again, that only matters if you had lots of curl
commands each with its own >> file open. But your code had one >> open
and lots of echoes (well, curls) using it.

Which is it? (Actually, both should work. But we need to know what is
actually goging on.)

Cheers,
-- 
Cameron Simpson <cs@xxxxxxxxxx> DoD#743
http://www.cskk.ezoshosting.com/cs/

BTW, this is an informal explanation, and if any linguists wish to point out
any fallacies, they are free to go and fuck themselves.
        - pettsj@xxxxxxxxxxxxxxxxxxxx (James Petts)
-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org


[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux