08-21-2006
Quote:
Originally Posted by jim mcnamara
I'm confused. Are you trying to call popen() against an already existing process?
Or is the process being created becoming a background process with no controlling terminal?
In either case popen will not work. As you know. You can test to see if popen is still working with a valid stream. popen returns a FILE *ptr, so you can call (on Linux) isastream(fileno(ptr)) or more generally ioctl(fileno(ptr), I_CANPUT,0). These will return errors approiately. Assuming I understand what you're asking...
You may also want to check out the isatty() function.
this is the situation...
dedicated server program which is a background process without any controlling terminal which forks another server instance to handle client requests...
in that the program handling a client request - it checks whether a particular process is running or not..
the command string is framed it and it is passed to the popen function call and it fails there...
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello all,
How do I start a background process and save the process id to a file on my system. For example %wait 5 & will execute and print the process id. I can't figure out how to get it to a file. I've tried: > filename 0>filename 1>filename.
Any assistance is most appreciated.
Thanks,
Jim... (10 Replies)
Discussion started by: jleavitt
10 Replies
2. Shell Programming and Scripting
Hi,
In shell script when I use
script1 >> filelog
the echo statments of script1 gets printed in the filelog
but when I try to run script in background i.e,
script1 & >> filelog
nothing gets printed in the filelog.
Anybody knows whats going on here.
thanks (3 Replies)
Discussion started by: k_oops9
3 Replies
3. UNIX for Dummies Questions & Answers
How, can I hide background process's output? (5 Replies)
Discussion started by: zylwyz
5 Replies
4. Shell Programming and Scripting
Hello,
This has probably been answered in other forms, however I would like to confirm this statement before I use it in production. Will this syntax work for a background process?
echo "nohup server_process1 >/dir1/nohup.server_process1 2>&1 &" | ksh
Please advise. Thanks (1 Reply)
Discussion started by: jerardfjay
1 Replies
5. Shell Programming and Scripting
i gave a copy process in the background( to copy around 100GB) , while in progress, the session got terminated. when i relogged in and checked the destination folder the copying was in progress... how could it happen(copying) when the shell terminates??? :rolleyes: (2 Replies)
Discussion started by: vinod.thayil
2 Replies
6. UNIX for Dummies Questions & Answers
What I need to learn is how to use a script that launches background processes, and then kills those processes as needed.
The script successfully launches the script. But how do I check to see if the job exists before I kill it?
I know my problem is mostly failure to understand parameter... (4 Replies)
Discussion started by: holocene
4 Replies
7. AIX
how to check the process running in background? how can i run a process in background? pls explain with commands (1 Reply)
Discussion started by: udtyuvaraj
1 Replies
8. Shell Programming and Scripting
Hi,
I am using net::ftp for transferring files now i am trying in the same Linux server as a result ftp is very fast but if the server is other location (remote) then the file transferred will be time consuming.
So i want try putting FTP part as a background process. I am unaware how to do... (5 Replies)
Discussion started by: vanitham
5 Replies
9. Shell Programming and Scripting
Hi,
I have written a menu driven shell script in which as per the choice, I run the another script on background.
For eg:
1. get info
2)process info
3)modify info
All the operations have different scripts which i schedule in background using &.
However I wish to display the error... (0 Replies)
Discussion started by: ashima jain
0 Replies
10. Shell Programming and Scripting
Here is my test code
process = sp.Popen( + ,
bufsize=1,
universal_newlines=True,
stdout=sp.PIPE, stderr=sp.STDOUT,
cwd=src_home)
output, _ =... (2 Replies)
Discussion started by: ezee
2 Replies
pclose(3) Library Functions Manual pclose(3)
NAME
pclose - Closes a pipe to a process
LIBRARY
Standard C Library (libc.so, libc.a)
SYNOPSIS
#include <stdio.h>
int pclose (
FILE *stream );
STANDARDS
Interfaces documented on this reference page conform to industry standards as follows:
pclose(): XPG4, XPG4-UNIX
Refer to the standards(5) reference page for more information about industry standards and associated tags.
PARAMETERS
Points to a FILE structure for an open pipe returned by a previous call to the popen() function.
DESCRIPTION
The pclose() function closes a pipe between the calling program and a shell command to be executed. Use the pclose() function to close any
stream you have opened with the popen() function. The pclose() function waits for the associated process to end, and then returns the exit
status of the command. If the original processes and the process started with the popen() function concurrently read or write a common
file, neither should use buffered I/O. If they do, the results are unpredictable.
RETURN VALUES
Upon successful completion, the pclose() function returns the exit status of the command.
If an error is detected, pclose() sets errno to an appropriate value and returns a value of -1.
ERRORS
If the pclose() function fails, errno may be set to the following value: The status of the child process could not be obtained.
RELATED INFORMATION
Functions: fclose(3), popen(3), wait(2)
Standards: standards(5) delim off
pclose(3)