35 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
0
votes
1
answer
133
views
how to get the file size before closing the process ? pclose()
I want to check the file size ("compressed filesize") before closing the file .pclose()
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#...
0
votes
2
answers
75
views
C++: fgets issue in getting command terminal data
I am writing a C++ program for an embedded Linux application for a custom device. Very often, I run Linux terminal commands via popen and pclose. If I need to only check whether the command was ...
0
votes
1
answer
117
views
PHP on Windows, how to run a script in the background?
I've tried all these commands:
$cmd = "start /B php $rootPath\\$scriptName ";
$cmd = "php $rootPath\\$scriptName > NUL 2>&1 &";
$cmd = "php $rootPath\\$...
1
vote
0
answers
191
views
C++ Windows _pclose return value: _cwait needed?
I want to get the exit status of a pipe in C++, both on Linux and on Windows, to check whether a command ran successfully.
On Linux (or POSIX more generally), it appears that the macros in <sys/...
3
votes
1
answer
819
views
WEXITSTATUS returning invalid exit status of popen() on success case
I am trying to get the exist status of the child process using popen().
Case 1: Calling function with the shell command returning error. This is working as expected.
func("du -sh _invalid_file_&...
3
votes
1
answer
1k
views
How to get the correct exit code of a shell command executed via pipe using popen() and pclose() in a daemonized process?
I'm writing a C++ daemon that is going to run on a Linux embedded system and execute a shell command. I'm trying to get both the output of the command (stdout) as well as the exit code of said shell ...
0
votes
0
answers
91
views
Is there any problem with popen stream to be closed after fdopen
I'm seeing a strange issue. Sample code is included below
When this code is run with valgrind, it complains that the memory allocated with popen is still reachable. Should i worry about this warning? ...
1
vote
1
answer
287
views
Why does this pclose() implementation return early with ECHILD unless invocation is delayed after popen()?
I recently wanted to get my hands dirty with understanding how to fork/exec a child process and redirecting stdin, stdout, and stderr thereof, by way of which I wrote my own popen() and pclose()-like ...
1
vote
0
answers
207
views
Why does pclose return prematurely?
UPDATE 1: This question has been updated to eliminate the multithreading, simplifying its scope. The original problem popened in the main thread, and pclosed the child process in a different thread. ...
0
votes
0
answers
181
views
popen, pclose and getdelim functions not included in Turbo C library
This question is pretty straightforward....
The pipe functions (popen, and pclose) and getdelim functions are not included in the Borland Turbo C Libraries I'm using.
I'm unable to compile any code ...
1
vote
1
answer
232
views
Segmentation fault when pclose after fscanf
I try to get lost packets number (from ping command on raspberry) which I use for sim switching on router. I tried to do that with code at the bottom (reduced to error causing part), but when I try to ...
3
votes
4
answers
4k
views
Is output read from popen()ed FILE* complete before pclose()?
pclose()'s man page says:
The pclose() function waits for the associated process to terminate and returns the exit status of the command as returned by wait4(2).
I feel like this means if the ...
0
votes
1
answer
2k
views
Pclose seems to make process fail
This question is a follow up of this question : Controlling a C daemon from another program
My goal is to control daemon process execution from another program. The daemon's code is really simple.
...
3
votes
1
answer
3k
views
C++ popen pipe doesn't close correctly with pclose for "ps aux" command
I am running MacOS and want to execute the "ps aux" command and get its output through my application. I have written a method which executes commands using popen function:
std::string exec(const ...
1
vote
0
answers
160
views
Segmentation fault after realloc
this is my code:
void Available_firmware_version(){
char *version = (char *) malloc(2);
strcpy(version, "");
FILE *fp;
int status = 0;
char path[PATH_MAX];
fp = popen("swift list Manto", "r");
if (...