Sponsored Content
Top Forums Programming using popen with background process Post 302085944 by jim mcnamara on Monday 21st of August 2006 09:46:12 AM
Old 08-21-2006
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.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

capture the process id when starting a background process

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

background process

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

background process

How, can I hide background process's output? (5 Replies)
Discussion started by: zylwyz
5 Replies

4. Shell Programming and Scripting

background process

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

background process

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

Script to start background process and then kill process

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

Background process

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

How to put FTP process as a background process/job in perl?

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

Make background process interact with fg process

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

Subprocess.popen() should write to log without waiting for process to complete

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
explain_popen_or_die(3) 				     Library Functions Manual					   explain_popen_or_die(3)

NAME
explain_popen_or_die - process I/O and report errors SYNOPSIS
#include <libexplain/popen.h> FILE *explain_popen_or_die(const char *command, const char *flags); DESCRIPTION
The explain_popen_or_die function is used to call the popen(3) system call. On failure an explanation will be printed to stderr, obtained from explain_popen(3), and then the process terminates by calling exit(EXIT_FAILURE). This function is intended to be used in a fashion similar to the following example: FILE *fp = explain_popen_or_die(command, flags); command The command, exactly as to be passed to the popen(3) system call. flags The flags, exactly as to be passed to the popen(3) system call. Returns: This function only returns on success, see popen(3) for more information. On failure, prints an explanation and exits. SEE ALSO
popen(3) process I/O explain_popen(3) explain popen(3) errors exit(2) terminate the calling process COPYRIGHT
libexplain version 0.52 Copyright (C) 2009 Peter Miller explain_popen_or_die(3)
All times are GMT -4. The time now is 04:47 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy