LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-21-2022, 07:58 PM   #1
BudiKusasi
Member
 
Registered: Apr 2017
Distribution: Artix, MX
Posts: 327

Rep: Reputation: Disabled
Prevent output race in bash shell terminal


How do we prevent output race in bash terminal as printing out multiple processs in multi command with a piping ?

Last edited by BudiKusasi; 10-21-2022 at 08:10 PM.
 
Old 10-21-2022, 08:23 PM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,612

Rep: Reputation: 1680Reputation: 1680Reputation: 1680Reputation: 1680Reputation: 1680Reputation: 1680Reputation: 1680Reputation: 1680Reputation: 1680Reputation: 1680Reputation: 1680
By removing code with race conditions.
 
Old 10-21-2022, 11:08 PM   #3
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 6,540
Blog Entries: 3

Rep: Reputation: 3410Reputation: 3410Reputation: 3410Reputation: 3410Reputation: 3410Reputation: 3410Reputation: 3410Reputation: 3410Reputation: 3410Reputation: 3410Reputation: 3410
Quote:
Originally Posted by BudiKusasi View Post
How do we prevent output race in bash terminal as printing out multiple processs in multi command with a piping ?
Please show an example of what you have in mind, even in a simplified form. The more specific code example you can provide, the more specific answer you can get -- and vice versa.
 
Old 10-21-2022, 11:22 PM   #4
!!!
Member
 
Registered: Jan 2017
Location: Fremont, CA, USA
Distribution: Trying any&ALL on old/minimal
Posts: 997

Rep: Reputation: 381Reputation: 381Reputation: 381Reputation: 381
Interleave might be the missing keyword in your problem. @OP: yes?

https://stackoverflow.com/questions/...ving-behaviour

Try this web search (to find more info to describe your problem):
Linux pipe output interleaved
 
1 members found this post helpful.
Old 10-22-2022, 09:27 AM   #5
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 19,248

Rep: Reputation: 6525Reputation: 6525Reputation: 6525Reputation: 6525Reputation: 6525Reputation: 6525Reputation: 6525Reputation: 6525Reputation: 6525Reputation: 6525Reputation: 6525
you need to collect those outputs independently, into different files. And print them when you want.
 
Old 10-22-2022, 05:58 PM   #6
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 10,701

Rep: Reputation: 5062Reputation: 5062Reputation: 5062Reputation: 5062Reputation: 5062Reputation: 5062Reputation: 5062Reputation: 5062Reputation: 5062Reputation: 5062Reputation: 5062
Quote:
Originally Posted by Turbocapitalist View Post
Please show an example
This.

But generally speaking, you solve it by sending the output of each command to a different place.

Last edited by dugan; 10-22-2022 at 06:01 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Preventing terminal output race of a Bash' sub process by `>( )` and its following command BudiKusasi Linux - Software 2 10-22-2021 09:55 PM
How to prevent "leak" into Shell from a customized shell menu script dctw Programming 11 12-28-2009 05:02 AM
Prevent race conditions in SSH, PERL aarontwc Programming 9 12-04-2008 01:51 AM
Linus Torvalds enters race for California Governor bosewicht Linux - General 2 09-02-2003 01:13 PM
Linus Torvalds enters race for California Governor fancypiper General 10 09-02-2003 01:11 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration