How can I get around this? when my program reaches the following popen job it halts the program until the ping/netstat/ipconfig/traceroute is completed then resume to the rest of the program...
So I figured I could run the process with no hangup and in background so I went
It still halt the program until the ping is completed... the only difference im getting is in the meantime the program is halted I get
nohup: redirecting stderr to stdout
nohup: redirecting stderr to stdout
nohup: redirecting stderr to stdout
nohup: redirecting stderr to stdout
Are you trying to stream the output of ping as and when it completes 1 round trip. Is this something to be extended to multiple servers running ping in parallel as a background job?
You are getting error output from ping - change the command
When you have a subprocess running it generates a system signal (which is being trapped by popen and reported). The signal is SIGTTOU. You cannot use popen without trapping stderr output or blocking signals.
I anticipated that the commands would take some time to completed and store the command outputs in the arrays so I put the menu after and made some dummy progress bar that are executed upon chosing the NETWORK TEST option... to allow enough time for the ping/netstat/ipconfig/traceroute to be completed BEFORE the program tries to send the stored command output in the arrays through the socket via smtp to my email.
Problem is that when I execute the program... it takes like 1 minute before the menu appear because the menu doesn't appear until the 4 commands are completed... And I need the menu to appear right upon execution...and these commands to be run in the background WHILE the Im chosing one of the menu option then 4 progress bars comes up and ensure that the tests had enough time to complete then after the 4 progress bar are completed the socket is initiated and the content of the arrays are pushed through it to a smtp and then ends up in my email...
How can I get these commands to be run in the "background" so that the menu appears upon execution of the program?
I am not sure if I grasped what you are trying to achieve. It seems that you want the popen() functions being executed "in background" while your program is doing other useful tasks, like building the menu. If so, threads could be an elegant solution to your problem. In one thread, you run your popen commands, while another thread takes care of the menu and progress bar.
I paste a simple example to illustrate my point. If you want to compile, you need to enable pthread (on many platforms, this is achieved passing the flag -pthread to the C compiler. But check your local doc).
Yeah, I knew it could be done with thread I felt a bit lazy I wondered if there was a "quick and dirty" way without having to rewrite too much of my codes. Also I need to port it to Windows after im done with the Linux/Mac by i've seen pthread-win32 so i guess i can work around that thanks again
I have two programs, DriverScale.c and scale9.c. DriverScale.c calls scale 9.c which sends a W and a carraige return to the scale which SHOULD return the weight to DriverScale. However scale 9 hangs for at least 10 min, and then finally returns the weight.
Compilation:
... (8 Replies)
I need UNIX scripts for polling, Uncompressing files and moving files between directory. Also trying to save file paths and any other variables in an independent file (.env) and use these at runtime by executing this file in the main script. (3 Replies)
I have a ksh script (script1) that calls another ksh script (script2). If script2.ksh hangs or takes too long to execute I want script1.ksh to kill the call to script2.ksh and instead just display "Script2 can't run right now". Could someone help me with coding this? (1 Reply)
I am scheduling a task at regular intervals at seconds acuracy using crond and sleep command . my data in crontab file is as below:-
the above line is working fine when we are creating this crontab file before 00:05 min .
But when we are creating the crontab file at 00:05min , unable to... (10 Replies)
//Find the root of the equation (x^2)-2 by bisection method.
#include<iostream>
using namespace std;
double a,x;
double f(double x)
{
return ((x*x)-2);
} //Suppose the function is (x*x)-2.
void calcx(double a1,double b1)
{
x =... (2 Replies)
I'm trying to execute a script from within my java code. The execution of the script is over(it's pid is no more), but java is stuck on waitFor() method of the shell script process!. And yes, I'm reading output and error streams in 2 separate threads. Yes, they are being joined at the end(after... (0 Replies)
Hello experts,
How can I retrieve the output from a Unix command and use it as string variable in my C program?
For example, when I issue the command 'date' I get:
Tue Jun 11 09:54:16 EEST 2009
I do not want to redirect the output of the command to a file and then open the file from... (3 Replies)
I have made use of 'valgrind' and -finstrument-functions compiler option for debugging / analyzing code. Both the options lets us know the line / file being executed to some extent.
Is there a generic way that lets program dump the file:line it is getting executed dumped to a log file during... (3 Replies)
Hi,
I wanted to know if i can write a program using switches and signals, etc to trace execution of other unix program which calls c program internally.
If yes how? If not with signals and switches then are there any other methods apart from debugging with gdb/dbx. (3 Replies)
Hi ,
I m actually trying to implement pipes program,but after executing the execvp(),my program is getting hanged up :mad:
Actaully i m getting the desired output expected from execvp()...but once results are displayed on the output screen ,program is getting hanged up
values of... (3 Replies)