Hello,
I want to redirect the output of two or more processes to the same file.
What happens if the information is written at the same time.
Can I rely on the Operating System (AIX 4.x), that all information is
written into the output file.
Thanks
Thanks
--
Jens-Uwe Mager <pgp-mailto:62CFDB25>
Further, it will be by "write()" and not by any standard you imply.
IE, if you have a sentence but it takes 2 write() system calls to print it,
you
might have a "write()" from the other process interrupt them.
Further, the "printf()" functions are buffered, and by default are fully
buffered.
You either have to force the write or depend on it writing to the actual
file
every 4K of data.
>Thanks
> Yes, but you can't guarantee that the data will be in the order you want.
> Further, it will be by "write()" and not by any standard you imply.
> IE, if you have a sentence but it takes 2 write() system calls to print it,
> you
> might have a "write()" from the other process interrupt them.
> Further, the "printf()" functions are buffered, and by default are fully
> buffered.
> You either have to force the write or depend on it writing to the actual
> file
> every 4K of data.
> >Hello,
> >I want to redirect the output of two or more processes to the same file.
> >What happens if the information is written at the same time.
> >Can I rely on the Operating System (AIX 4.x), that all information is
> >written into the output file.
> >Thanks
i only used this with scripts started interactively, though.
it probably won't work if you start them via cron or at.
and it only affects the scripts output ... programs called
within the script still do buffered io, unless you use
setlinebuf()
i still find it useful, sometimes
regards,
juergen
>> > Further, the "printf()" functions are buffered, and by default are fully
>> > buffered.
>> > You either have to force the write or depend on it writing to the actual
>> > file
>> > every 4K of data.
>my "solution" to the problem is not to redirect the
>output of the scripts (which would make the output buffered
>and therefore lead to scrambled output), but
>in the scripts via "exec >> mylogfileorwhatever 2>&1".
>this redirects the output, yet it remains line-buffered.
>i only used this with scripts started interactively, though.
>it probably won't work if you start them via cron or at.
>and it only affects the scripts output ... programs called
>within the script still do buffered io, unless you use
>setlinebuf()
>i still find it useful, sometimes
>regards,
>juergen
--
Jens-Uwe Mager schrieb:
> >I want to redirect the output of two or more processes to the same file.
> >What happens if the information is written at the same time.
> >Can I rely on the Operating System (AIX 4.x), that all information is
> >written into the output file.
> If you open the file for append (>> using the shell) then the OS will make
> sure that output is always appended at the end of the file.
I take it that the original question refers to concurrent processes.
My approach would be:
1) Explicitly 'open()' the file in the program, using the O_APPEND
flag, maybe even O_SYNC (probably overkill - try both with and
without).
2) Explicitly use 'write()', not the STDIO-functions.
If you want to use STDIO-functions like 'fprintf()', also use
'fflush()' at proper places - before the buffer fills !
You would then need to combine 'open (... , O_APPEND)' with
'fdopen()', I have never done that.
HTH
Joerg Bruehe
--
Joerg Bruehe, SQL Datenbanksysteme GmbH, Berlin, Germany
(speaking only for himself)
1. Redirecting to TWO output files
Hi,
I have a program how write some lines to the terminal (stdout).
Not all the lines are of this kind. I would like to use
a script with awk and/or sed to be able to redirect EACH group
to a different output file. Now, what I do is running the program
file.
Can anybody help me? Thanks.
J C
--
357-"Funny, doesn't *look* like a cyberpsycho...." {but it
was one}
("FAMOUS LAST WORDS", collected by O.Rosenkranz)
====================================================================
* J. C. Gonzalez
. ------------------------------------------------------------
. Max-Planck-Institut fuer Physik Tel.: +49 89 32354445
. (Werner-Heisenberg-Institut) Fax : +49 89 3226704
* Foehringer Ring, 6 ... . .... . ..... ......... ..
. Deutschland WWW: www.gae.ucm.es/~gonzalez
====================================================================
3. redirecting a process output
5. Help: redirecting process input/output
6. how to configure to use null modem port?
7. redirect output from child process into parent's stdout
8. Sun E450/Clariion E3200 RAID scsi problem
9. How do I redirect process output?
10. redirect output after a process has started
11. redirected output from a killed process
12. Suspend process, then "bg > some_file" with output redirected
13. Q:redirecting output while source process is running