Programming :: Shell Script: Wait On Two Processes At The Same Time?

Mar 16, 2010

I'm writing a script that needs to spawn 2 or more processes and wait for their return status. I have a method to do this by waiting on each process individually like this:

Code:
process1 &
PID1=$!

[code]...

View 14 Replies


ADVERTISEMENT

Programming :: Set Period Of Time To Tcp Connection To Wait For Request Or Respond For Tcp Block Read

Feb 27, 2010

I wanted to know how can I set a period of time to a tcp connection to wait for request or respond for tcp block read. which system call or function I can use? Does any body know a very simple quick and easy reference on web for socket programing that has lots of socket programing examples in it?

View 1 Replies View Related

Programming :: Measure Time Of N Processes?

Oct 24, 2010

how can I measure time of N processes and N threads and then compare this time to prove that threads are faster than processes. understanding C code, or also for some good way to measure time of N processes and N threads for C.

View 5 Replies View Related

Software :: Check Which Processes Are In Wait Cpu Cycle?

Aug 10, 2010

My mail server is presenting a high wait time (see attachment) that sometimes reaches 80%. How can I check which processes are doing that?

View 1 Replies View Related

Programming :: Bash Shell Scripting / Using The Sort Command To Sort The Top 5 CPU Processes?

Feb 28, 2010

What options should I use when I'm using the sort command to sort the top 5 CPU processes (ps -eo user,pid,ppid,%cpu,%mem,fname | sort ??? | head -5) showing max to min usage?

View 2 Replies View Related

General :: Make Shell Script Wait For A Particular Key Pressed In Order To Proceed?

Jan 30, 2010

i've been searching all over the internet for a way to let the user press a particular key let's say 'y' without the user having to press [Enter] as confirmationfor yes, this would then run another function.

Quote:

Book Inventory Summary Report:-

Title, Author, Price
______________________________
StarWars EP1, G.Lucas, $49.59
Harry Potter, Rowling, $45.98
The Matrix, Mr. Smith, $53.98

Press 'y' to make a copy of this result into a file or 'n' to return to the main menu.. I understand the "press any key to continue" would go something like

Code:

read -sn 1 -p "Press any key to continue.." But i try many different ways of getting the "press a particular key" function, and none of them works.

View 5 Replies View Related

Programming :: Timer In Socket Programming - Wait For X Sec After Read() And Then Disconnect The Client Connection

Mar 8, 2011

I have a server listening on incoming client connections. Once the client establishes SSL connection with the server, the server waits on read() from the client. Only Client can disconnect the connection. I want to have a timer in the server program to wait for x secs after read() and then disconnect the Client connection.

View 3 Replies View Related

General :: Kill All Processes Except Shell Window?

Aug 3, 2010

i was referring to an article given in following website.[URL] I was surprise to know that i can kill all running processes by using kill 0. However when i tried running the command nothing happened.

my machine details:

Code:

# lsb_release -a
LSB Version: :core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch
Distributor ID: EnterpriseEnterpriseServer
Description: Enterprise Linux Enterprise Linux Server release 5.2 (Carthage)
Release: 5.2
Codename: Carthage

View 4 Replies View Related

Programming :: Read Two Files Word By Word At A Time Using Any Loop By Shell Script?

Mar 4, 2010

Well, I am facing one issue:How can i read two files word by word at a time using any loop as i need word by word comparision in shell script?Please let me know pseudo code.

View 14 Replies View Related

Programming :: C++ Cin Doesn't Wait For Input By Operator

Jan 4, 2010

I am trying to learn C++.I implemented a simple archive program, and I am in a situation in which the user is prompted by a menu to make a choice.So I have some cout instruction to illustrate the possible choices and then

int choice;
cin>>choice;

and everything works fine.I introduced this code in a "while" loop that checks wether the choice made by the user is valid or not:

bool check=true;
int choice;
while(check)
{
cin>>choice;
if(the choice is valid) {...;check=false}
else cout<<"please make an other choice"
}

What is happening is that if by mistake the user introduces a character in place of a number, the loop repeats indefinitely because the program, when it get to the "cin" instruction, does not pauses to wait for a new input.

View 7 Replies View Related

Programming :: Read From Stdin In Perl Do Not Wait For EOF?

Apr 28, 2010

I am trying to read one line at a time in perl and not wait for stdin eof to start the action:

Code:
foreach(<STDIN>){
<do something>
}

if i pipe ls into it, it waits for ls to be done before doing the action.

View 1 Replies View Related

General :: Writw Shell Script To Kill Processes?

Oct 19, 2010

I am trying to write a script which when executed should kill all currently running cat processes.

View 1 Replies View Related

General :: Shell Script Searches Processes Running?

May 20, 2010

how to write a shell script the searches for processes running on my system. I really don't know where to start. can anyone give me a hand and explain how the script works?

View 3 Replies View Related

General :: Real Time Processes ?

Dec 7, 2009

I've got the following problem:

1. I start two bash windows

2. In one of them I start a script test1:

Code:

This script puts a natural number 5 times a second.

3. Then in the second bash window I type (as root):

Code:

The script test2 looks as follows:

Code:

While true; do
true;
done

During the following 15 seconds test2 is the process with the highest real-time priority. As far as I know the script doesn't perform any system calls so it shouldn't be suspended even for a minimal timeslice. My question is: why the process test1 manages to put a few numbers on the screen before test2 stops. I thought that test2 would exclusivly own the processor for 15 seconds.

View 8 Replies View Related

General :: List The Currently Running Processes Via Code A Shell Script?

Feb 5, 2011

how to list the currently running processes via code a shell script. FYI i now about the top method in the terminal but i need a way to have it via a shell script.

View 4 Replies View Related

General :: Automatically Kill Processes That Over Time Uses 95%+ Of Resources?

May 3, 2010

I don't know about your computer but when mine is working properly no process is sucking 95%+ over time. I would like to have some failsafe that kills any processes behaving like that. This comes to mind because when I woke up this morning my laptop had been crunching all night long on a stray chromium child process.

This can probably be done as a cron job, but before I make it a full time job creating something like this I'd thought I should check here. :) I hate reinventing the wheel.

View 1 Replies View Related

Ubuntu :: Find Cumulative CPU Time For Processes For An Interval?

Feb 20, 2010

I want to find the cumulative CPU time used by each process between two points (defined by the user, e.g. running a command or clicking a button).

A first stab at this would be running

Code:
ps -eo pid,cputime

at the beginning of the interval and at the end, then doing some arithmetic on the two sets of results. But this only shows whole seconds of cputime ... and what about processes that started and stopped during the interval?

View 1 Replies View Related

Software :: Which Value Is For Highest Priority For Real-time Processes

Dec 18, 2009

I want to set my program with highest priority for real-time processes. I understand the priority for real-time processes ranges from 1-99, but I get completely confused after reading Understanding the Linux Kernel and the manual of sched_get_priority_max(): which value has higher priority? either 1 or 99. Understanding the Linux Kernel says 1 has highest priority but sched_get_priority_max() returns 99 for SCHED_FIFO and SCHED_RR policy.

View 3 Replies View Related

Programming :: Socket Server Using Pthread Doesn't Wait For Accept() Properly?

Apr 19, 2010

I'm building a simple(?) socket server using threads to serve up a few requests. The spec is such that I have to listen to three ports at once, so I decided to use pthread to create three separate threads that would wait for connections, then spawn new threads to handle them.

The problem is that when I do this, for some reason the program never enters the wait loop and instead terminates (All three threads did get created since the messages get printed properly.) It gets to the line which prints "???", but not the line after the accept() call.I don't see an open port when I check for one either so I'm 99% sure they're terminating.Basically I have a main() method which has three calls to pthread_create, which should result in three threads being run that all wait for connections (listenOnPort). After each thread creation I print some info to make sure it's actually being created.

By the way, when I just run listenOnPortwithout threading, the server appears to enter the loop correctly and seems to be waiting for requests. It's only when I run the functions as threads that the problem seems to happen.The source is attached below. Any help will be appreciated. Much of the code is borrowed from a website (I can't post it because I am new here.) You need not worry about the handler_ methods because those are just methods that are run by the threads themselves.

Also--the original source was in C and I changed it to C++. Should I just use C?
server.h Code: /*
* server.h

[code]....

View 1 Replies View Related

Ubuntu :: Starting Processes At Boot Time - Don't Start Privoxy?

Apr 27, 2010

I installed and configured privoxy - everything worked nicely when I run it manually by

Quote:
/etc/init.d/privoxy start

After restarting the computer privoxy wasn't start automatically. I checked the links in /etc/rcX.d - are o.k. I installed sysv-rc-conf - shows that for runlevel 2 - 5 privoxy is running. I changed /etc/rc2.d/S20privoxy to /etc/rc2.d/S99privoxy - to start that process at the end. I installed Boot-Up Manager. Privoxy is marked for start automatically. I added in /etc/rc.local line: /etc/init.d/privoxy start

Privoxy still doesn't turn on at boot time and every time I must start it manually. Could you tell me how could I repair this ?

View 4 Replies View Related

Ubuntu :: Standby / Suspend: Fails 2nd Time On 'Freezing User Processes'

Feb 11, 2010

I have what I think is a somewhat different failure of standby than I've seen listed on other threads, and I'm stumped.The system hangs on this for a while, then comes back to the login screen without going into standby. This ONLY HAPPENS on a SECOND standby attempt--the first standby after booting ALWAYS succeeds.The standby log doesn't indicate any failures.I had made other changes previously that temporarily got standby working consistently:/etc/default/grub: GRUB_CMDLINE_LINUX_DEFAULT="quiet splash usbcore.autosuspend=-1"

View 1 Replies View Related

Programming :: Shell Scripting / Create A Shell Script Similar To Ls?

Jun 5, 2011

I am trying to create a shell script similar to ls, but which only lists directories. I have the first half working (no argument version), but trying to make it accept an argument, I am failing. My logic is sound I think, but I'm missing something on the syntax.

Code:
if [ $# -eq 0 ] ; then
d=`pwd`
for i in * ; do
if test -d $d/$i ; then
echo "$i:"
code....

View 10 Replies View Related

Programming :: Bash-shell-like Less Functionality In The Python Shell?

Jun 25, 2010

Is there some type of functional way to read things in the Python shell interpreter similar to less or more in the bash (and other) command line shells?

Example:

Code:

>>> import subprocess
>>> help(subprocess)
...
[pages of stuff to read]
...

I'm hoping so as I hate scrolling and love how less works with simple keystrokes for page-up/page-down/searching etc.

View 4 Replies View Related

Programming :: Read Keyboard Status (not: Wait For Keyboard Input)?

Jun 28, 2011

has bash a command that reads the keyboard status and exits? I want to write a loop of this form:

Code:
while [ 1 ] do
sleep (1)

[code]....

View 14 Replies View Related

Programming :: Creates A Child Process With Fork And, When The Child Ends, Receives The SIGCHLD Signal And Wait For Its Termination?

May 23, 2011

I have a doubt about signals in C programming. I have done this little program to explain it. It creates a child process with fork and, when the child ends, receives the SIGCHLD signal and wait for its termination.Ok, quite easy, BUT when I execute this code the SIGCHLD signal is received twice, first as an error (returns -1) and the second one to finish the child process.I don't understand the meaning of the first received signal. Why is it generated? Is the code wrong? (if you add the SIGINT and press Ctrl+C during the execution it also receives two signals instead of one)

Code: #include <stdio.h>
#include <unistd.h>
#include <string.h>

[code]....

View 4 Replies View Related

Programming :: Bash Wait For One Line To Finish Before Going To The Next Line?

Jan 10, 2011

I have a wrapper script called MAIN.sh that runs several other script. It looks like this:

Code:
#! /bin/sh
script1.sh

[code]...

View 6 Replies View Related

Programming :: Implement Two Periodical Processes In C++?

Jul 28, 2010

I am doing real time programming in C++, under Linux. I have two processes, let me say A and B. A process is being started periodically, every 5ms. B process is being started every 10ms. The process A is doing data processing. The process B is reading that data and displays it. I am confused about how to run periodically processes. The problem is that the period of process A should be as much as it is possible accurate (5ms). For the process B it isn't so important. I have created independent processes, each in one .cpp file, and I am starting them from bash file. Is that OK? I don't have to make child processes in order to have parallel processes?

View 1 Replies View Related

Programming :: Different Processes Using Same File Object

Sep 29, 2009

I have 2 completely different processes A and B (they do not have any relationship) suppose A opens a file with file descriptor 4 and B opens another file with file descriptor 5

Can process A use the fd 5 (i.e using the file object of processs B) by any means..if suppose i let the fd 4 of process A to point to the file object of process B(fd 5) will it work? is it safe?

View 3 Replies View Related

Programming :: How To Kill Zombie Processes

Dec 3, 2010

I have my code with my fork in a server and each time a client connects one more process is created. i use this code for the handling of zombies

void sig_chld(int signo){//Diadikasia gia tin diagrafi twn 'zombies'
signal( SIGCHLD, sig_chld );//signal gia ton entopismo tou zombie
pid_t pid;

[code]....

but i need the server to kill each zombie after the client is disconnecting and not to have to press ctrl+c

View 1 Replies View Related

Programming :: Switch Between Processes When Debugging With Gdb?

Feb 11, 2011

How to switch between processes when debugging with gdb?

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved