Breaking "while read" also breaks the parent process
Hi,
I'm a bit confused. Maybe some master can explain to me what is happening.
I have a program that starts issuing output about himself loading.
I want to run it in another thread but I want to wait untill it's fully loaded.
Program sample:
If I run it like this, it will stay in another thread but I will not be sure it is "up and running":
So I tried to run it like this but the process dies very soon : Question: How can I stat myprogram and wait untill it outputs "up and running"?
The reason your program is breaking is that the break will exit the loop, ending the read, which sends a SIGPIPE to myprogram, which usually is an exit condition.
Do you have influence on the code of the program being started? If so, have it create a file once it's done, for which you can wait.
If not you'll have to put the reading loop into the background, and have it signal the main program once it's done. Something like
Thanks pludi, I love your answer which is fairly new to me.
So basically you do:
Which I guess means: "waiting becomes 0 as soon as the signal USR1 is received"
And then you do:
Which I guess means: "Send signal USR1 to the process"
Can you confirm?
I read through man kill and I still have one question?
Are you strictly limited to the list of signals mentioned in the man page?
What makes you choose USR1?
I guess you need a safe signal that would not be easily used by other processes.
As for the signals, one is pretty much limited to the signals reported by "kill -l", minus a few. For example, SIGKILL can't be trapped. And for shell scripts there's the additional signal 0, which is triggered whenever the script exits (great for cleanup).
USR1 and USR2 are intended for use for IPC, as they have no fixed meaning. Other typical uses are SIGHUP (HangUP) to tell daemons to reinitialize themselves without restarting, SIGINT for catching ^C, or SIGWINCH when the terminal window was resized.
How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address
and column 3 contains “cc” e-mail address to include with same email.
Sample input file, email.txt
Below is an sample code where... (2 Replies)
Hi ,
I am trying to read a list of hosts from a config file and trying to get file list from that host. For this I have used one while loop.
cat "$ARCHIVE_CFG_FILE" | sed '/^$/d' | sed '/^#/d' | while read ARCHIVE_CFG
do
SOURCE_SERVER_NAME=`echo "$ARCHIVE_CFG" | awk -F '|' '{ print... (2 Replies)
I want to print any matching IP addresse in List1 with List 2;
List 1
List of IP addresses;
161.85.58.210
250.57.15.129
217.23.162.249
74.76.129.101
30.221.177.237
3.147.200.59
170.58.142.64
127.65.109.33
150.167.242.146
223.3.20.186
25.181.180.99
2.55.199.32 (3 Replies)
Hi,
Could anyone please shed some light on the following script lines and what is it doing as it was written by an ex-administrator?
cat $AMS/version|read a b verno d
DBVer=$(/usr/bin/printf "%7s" $verno)
I checked that the cat $AMS/version command returns following output:
... (10 Replies)
Hi,
I have line in input file as below:
3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL
My expected output for line in the file must be :
"1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL"
Can someone... (7 Replies)
Hallo,
i need a Prompting read in my script:
read -p "Enter your command: " command
But i always get this Error:
-p: is not an identifier
When I run these in c-shell i get this error
/usr/bin/read: read: bad option(s)
How can I use a Prompt in the read command? (9 Replies)
In this post, Perderabo's script says
echo 05/06/25 14:15:56 | IFS=" /:" read Y1 M1 D1 h1 m1 s1
which, if I am not wrong, will break the input into Y1, M1 et al.
I tried the following in my code
#! /bin/ksh
# per.sh
typeset -R2 HOUR=00
typeset -R2 MIN=00
typeset -R2 SEC=00
... (2 Replies)
Dears,
I've written a script which allows me to send mails in different formats with different attaches. Now I still want to add a feature to this script. My users would like to be able to receive a "read" or "delivered" receipt for their mails.
The script send mails on behalve of an specific... (1 Reply)