The sample actually executes the commands in parallel, but reads the output serially to demonstrate that the output was not intermixed.
Here's a small example of a main that starts a thread for each filename (up to 10) given on the command line. Each thread uses a popen() to cat the file (please no flames about useless uses of cat!!) and reads the data counting the number of times the character 'e' appears in the file. It's a silly (um, useless) programme, because the thread could open and read the file directly, but rather than invoking a ps or netstat command, I wanted something that I could repeat to ensure that the proper number of e's from each file were being counted (to prove no mixing of output from the commands).
The function invoked as the thread sleeps to demonstrate that the threads are indeed created in parallel -- all "create" messages from the main should print before any thread actually announces that it's running the command.
I am using a third party API to get some real time feed. When I run the command it shows the results properly:
etd@mhs-apps5009 $ mamalistenc -m lbm -tport mamaqa -S MLALERTS -s KANA wFinancialStatus
Type CTRL-C to exit.
(null).MLALERTS.KANA Type: INITIAL Status OK
wFinancialStatus |... (5 Replies)
Hi Perl Experts,
I am invoking a shell script thru a perl script and the perl script is cgi script.I need to capture the STDOUT of the shell script in the html page where I am invoking the script .?The shell script takes couple of mintutes to complete its execution .Mean while my html page does... (1 Reply)
I need to know what the upload speed of an Internet connection. I thought the easiest way to do this would be to transfer a file via FTP to my server using the command:
sh-3.2$ ftp -u ftp://username:password@computerdomain/directory/ file_to_be_uploaded
Note: My environment allows me to issue... (2 Replies)
Thanks in advance.
My environment is Ubuntu 9.04 desktop customized to be a high school classroom server for teaching code development. I have a unique "fake" jail called "lshell" which is very easy to setup and restricts users to commands that I dictate DISALLOWING ANYTHING ELSE. These... (6 Replies)
Hi,
i know how to
a) redirect stdout and stderr to one file,
b) and write to two files concurrently with same output using tee command
Now, i want to do both the above together.
I have a script and it should write both stdout and stderr in one file and also write the same content to... (8 Replies)
I have to read the file, in each line of file i need to get 2 values using more than one search pattern.
ex: <0112 02:12:20 def > /some string/some string||some string||124
i donot have same delimiter in the line, I have to read '0112 02:12:20' which is timestamp, and last field '124' which is... (4 Replies)
Hi all,
I've been looking around for this for a while and can't seem to find a satifactory way to do what I want:
I would like to assign the output of stdout to a variable and that of stderr to another one, and this without using temporary files/named pipes. In other words be able to assign... (4 Replies)
Hello.
From command line, the command zypper info nxclient
return a bloc of data :
linux local # zypper info nxclient
Loading repository data...
Reading installed packages...
Information for package nxclient:
Repository: zypper_local
Name: nxclient
Version: 3.5.0-7
Arch: x86_64... (7 Replies)
Hi All,
I have a requirement to execute multiple scripts (say 4) one after the other in one script and capture log details and error messages in a log file below
LOG_FILE= FILE.`date ++"%Y%m%d%H:%M:%S"`
Script 1 : File_Checkr.sh
Script 2 : Pre_Validation.sh
Script 3 : Testing.sh
Script... (12 Replies)
Discussion started by: Deena1984
12 Replies
LEARN ABOUT MOJAVE
pthread_join
PTHREAD_JOIN(3) BSD Library Functions Manual PTHREAD_JOIN(3)NAME
pthread_join -- wait for thread termination
SYNOPSIS
#include <pthread.h>
int
pthread_join(pthread_t thread, void **value_ptr);
DESCRIPTION
The pthread_join() function suspends execution of the calling thread until the target thread terminates unless the target thread has already
terminated.
On return from a successful pthread_join() call with a non-NULL value_ptr argument, the value passed to pthread_exit() by the terminating
thread is stored in the location referenced by value_ptr. When a pthread_join() returns successfully, the target thread has been terminated.
The results of multiple simultaneous calls to pthread_join() specifying the same target thread are undefined. If the thread calling
pthread_join() is cancelled, then the target thread is not detached.
RETURN VALUES
If successful, the pthread_join() function will return zero. Otherwise, an error number will be returned to indicate the error.
ERRORS
The pthread_join() function will fail if:
[EINVAL] The implementation has detected that the value specified by thread does not refer to a joinable thread.
[ESRCH] No thread could be found corresponding to that specified by the given thread ID, thread.
[EDEADLK] A deadlock was detected or the value of thread specifies the calling thread.
SEE ALSO wait(2), pthread_create(3)STANDARDS
The pthread_join() function conforms to ISO/IEC 9945-1:1996 (``POSIX.1'').
BSD January 23, 2010 BSD