Programming :: Get Error Code From Child Process?

Mar 28, 2011

I'm writing a sort of toy shell using fork() and execv(). It runs smoothly enough untill the user enters an invalid command at which point the program hangs, so I need a way to check if the program loaded using execv returned correclty or not in the parent process and kill it if it didntI tried writing stderr to a text file to see if something whent wrong but doesnt really work out. Try running ./digenv GDM -i -Q for instance. (-Q is an invalid option for grep which the program runs at a certain point).Heres the code:

//Carl Reg�rdh 2011-03-24


View 13 Replies


Programming :: Under Which Circumstances A Child Process Creates Another Child Process Using Fork

Dec 7, 2009

Consider the following code:


int main()
int i=0;
pid_t pid;


I get the following output:

Parent: chid_pid=4356 i=0 parent's pid=4355
This is child 4356 i=0
This is child 4357 i=1


I can observe instead of two children(as I expect) processes there are three. This is because child process 4356 creates its own child. Why all the messages of the type "This is child X i=Y" are concentrated one under another? How exactly fork works? Is affected by the fact that I have a dual-core processor?

View 3 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>


View 4 Replies View Related

Programming :: SetUID On Different PID Or Child Process

Aug 18, 2010

I have a root process (on linux) that forks a child and the child process then drops privileges by doing a setuid() to a normal user. After the child setuid()'s, it is of course impossible for it to gain root again by itself. But since the main process is still running as root, i was wondering if there was a simple/smart way of getting the root-master-process to elevate the child back to root (or maybe just to another non-privi uid). Is there some way to do a setuid() on another pid? or maybe something can be done through /proc/<pid>/? Killing the child is not an option (because its what it does today and im trying to find a smarter way). (The program is apache2's mpm-itk worker and the "child" is the actual apache2 process serving a page.)

View 11 Replies View Related

Programming :: Gdb Debugging Exec From Child Process?

Jul 14, 2011

Im using gdb for debugging my application.. I was able to debug child process(when fork comes) .. and in child process we have an exec call to .... So the problem is, when the control come to exec , the exec process is executing at a time... I could not debug the exec. process... error is stack curruption due to same frame So, is there any way to debug the exec process

View 1 Replies View Related

Programming :: How To Redirect Stdin For Child Process

Aug 18, 2010

I'm trying to write a shell script that do ftp and download file periodically, this script should be called by a daemon running in the background.

the shell script "" is as follows:

yafc ftp://test:test@ < commands
and the "commands" files is

d Root/md5* /

if I run it will work just fine. But when the daemon software calls the "", the script will send ftp login request to the ftp server, but will not even answer the username or anything.

I believe it is something about child process redirection, but I don't know how to deal with it.

This problem is not only with yafc, it is the same with any ftp client or any application like telnet and so.

View 4 Replies View Related

Programming :: Passing Arguments To A Child Process In C++?

Feb 7, 2010

what I am trying to do is to pass an argument to the standard input stream of a child process. I mean I create two programs .. first one invokes the other. second one contains something like


scanf("%d", &n);

now I want my first program to be able to pass a value to the second one so that it gets stored in n.

View 7 Replies View Related

General :: Killing Parent Process Without Killing Child Process (Linux C Programming)?

Mar 10, 2011

I want to kill parent process after "fork()" method. but if I kill parent process with "exit(0)" method, main() thread is terminated as well so child prosess doesn't work anymore. Is there any way to kill only parent process without affecting to child process?

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>


View 1 Replies View Related

Programming :: Fork()ing Multi Child Process In C - Stuck

May 12, 2011

i got basic knowledge about creating a single child from a parent using fork(). But when it comes into creating multiple children, i am simply stuck. I am trying to create two processes from a parent and it would wait for both two processes to finish. my attempt is as below


View 3 Replies View Related

Programming :: Redirecting The Output Of Child Process To New Xterm?

Aug 2, 2010

I am developing a application. In this I fork() 3 childs(lets say child1 , child2, child3) . The parent is now waiting for some input from keyboard.Child3 is continously getting data from child1 and child2 using pipe which it then will print using printf.Now as the parent is waiting for input from user through keyboard while child3 is continously printing the data. I want to do it in different terminals.Can you please guide me how to proceed ahead so that on one terminal , the parent waits for input fromser while on other terminal child3 prints data.

View 1 Replies View Related

Programming :: Parent Process Block - Status Of Child

Mar 22, 2011

I am going to create a parent process and fork a child process from it. I want to write a code in such a way that whenever my child process end it must indicate that the child process is terminated by a signal or not. This code must be written in the parent process block.

View 6 Replies View Related

General :: Difference Between Child THREAD And Child PROCESS?

Jul 30, 2009

I am troubleshooting something and I got this problem.

If I do "pstree -p"

It shows,



However, it does NOT show up in "ps -elf"


ps -elf | grep soffi
0 S whho 7734 1 0 80 0 - 36435 - 11:14 pts/2 00:00:03 /usr/lib/openoffice/program/soffice.bin -splash-pipe=5
0 S whho 7833 7759 0 80 0 - 751 - 11:21 pts/3 00:00:00 grep soffi

I was wondering if 7735, 7736, 7737, 7743 were really processes. Then I checked /proc, I could cd to /proc/7735, /proc/7736, etc, but I could not ls them out. I looked at the man page of "pstree", it says,


Child threads of a process are found under the parent process and are shown with the process name in curly braces, e.g.


So, what does all this mean? Does it mean that 7735, 7736, 7737, 7743 are just threads but not processes? If so, why could I cd to /proc/<id> but not see them in "ps -elf".

View 10 Replies View Related

Fedora :: Error Creating Child Process For This Terminal

Aug 4, 2009

Terminal will not open
Error message: There was an error creating the child process for this terminal
Got this after doing a update to testing repo; to try to fix another issue with my media player sound not working.

Just add yourself to 'tty' group and relogin

View 5 Replies View Related

Ubuntu :: There Was An Error Creating The Child Process Of This Terminal

Feb 13, 2010

I get the error

there was an error creating the child process of this terminal

When I run this code:

gnome-terminal --window-with-profile=Scripts

View 2 Replies View Related

Ubuntu :: Error Creating Child Process R-commander - On LTS 10.4

May 8, 2010

I work with social sciences and I really need to use "R". R is a program used for statistics and it has a module called R-commander, which let things easier to deal and comes with several options as opening SPSS files (another statistical package commonly used by Windows users) and other things. THe problem is, as Rcmdr is a module for R, when I run it, it opens a terminal window and then he runs the module, which opens a friendly gui.

It worked okay and clean in Ubuntu 9.10, but for LTS 10.4 I keep getting an error, no matter I reinstall the modules or the entire program. I even installed Ubuntu again without upgrading it from karmic Koala. But there is the same error msg.

The error message says: "Error while creating a child process for this terminal". The strange part is there is no other msgs in the terminal or errorlogs. I really need to use this software for work.

View 3 Replies View Related

Programming :: Disallow File Access For Child Process With Execv?

Mar 8, 2011

I need to disable file access (fopen, freopen, open etc) for application which is running under chroot jail and with restrictions (rlimit) via execv. Before that I redirected stdin/out to files within jail. I tried this:

// Redirect stdin/stdout to files
int fd = open (file_input, O_RDONLY);
if (fd < 0)
fatal_error ("input open failed!");


View 6 Replies View Related

Programming :: Fork() - Variable Values Between Child And Parent Process?

Feb 24, 2010


int main()
int pi;
int i=10;


Q 1. The value of the variable pid returned by the fork() function will be greater than 0 in the parent process and equal to zero in the child process? but during forking, there values are exactly copied so what's went wrong here?

Q 2. "changes to the variable in one process is not reflected in the other process" why it is so? >> Even if we have variable i declared as a pointer or a global it wont make a difference.


int main()
int i, pid;
printf("before fork i is %d


Q. Through this program it is clear that both process is using the data from the same location, so where's the original value is residing when the child process is in execution.?

View 6 Replies View Related

Programming :: Splitting A Parent Process Into 2 Child And Then Merging Result?

Sep 15, 2010

What i am trying to do is i want to add numbers from 1 to 100. but that too using multiprocessing. So i made a c programme and using fork() command made two child processes. Now in one child process i am adding from 1 to 50. and in another i am adding 51 to 100. and then in the parent process adding the two results to get the final one. Now the result from the two function i am getting correctly. But after the wait() call the value returned is lost : See the programme below for reference

# include<stdio.h>
# include<unistd.h>
# include<sys/wait.h>
# include<stdlib.h>


View 6 Replies View Related

Ubuntu :: Scanner - When Try To Save Image To Desktop Or File/folder - Message - Child Process Error

Jan 23, 2011

I have ubuntu 10.04.1 and a H.P.psc 1311 all-in-one printer scanner.Printer works ok but when trying to scan,with xsane,it goes through the scanning process and an image of the document comes up on the screen.

When I try to save this image to desktop or file/folder whatever I get the message; "Child Process Error. Failed to execute OCR command:GOCR:no such file or directory."

View 3 Replies View Related

General :: Sending Signal From Child Process To Parent Process?

Sep 8, 2010


#include <stdio.h>
#include <unistd.h>
#include <signal.h>


Description of what the code does or what i intended to do:

1. Created a child process from parent process using 'fork()'

2. Sent a signal 'SIGALRM' from child process to parent process using 'sigqueue' function.

(The Third parameter of 'siqueue' function contains the message (message msg) which the child process wants to send to the parent process.'msg' is a stucture instance containing a) pid of child and b) string) 5. Print the 'msg' sent by child process inside the signal handler function 'sig_action_function' of the parent process I am getting some junk value when this line is executed



I expected to get the pid of child process, which the child process sent to parent process through the signal.

View 3 Replies View Related

Ubuntu :: Error - E - Sub-process /usr/bin/dpkg Returned An Error Code - 1

May 9, 2011

I have just upgraded my ubuntu to 11.04 .After it is done ,I could install any software ,the error is as follows:

E: Sub-process /usr/bin/dpkg returned an error code (1)

I wonder what is the meaning of the error.

View 3 Replies View Related

Fedora :: Creating A Launcher - Error "Failed To Execute Child Process"

May 8, 2011

I am trying to create a launcher in Fedora 13 which will run a simple script named proj4a. I run this script from the command line as follows: $ /home/enowak/proj4a >/home/enowak/proj4a_out where proj4a is an executable file in my home directory and the output goes into a file, proj4a_out, in my home directory. Everything works fine.

I created a launcher called Proj4a and in the command field I entered the following: '/home/enowak/proj4a >/home/enowak/proj4a_out' When I click on the launcher it comes back with the following: There was an error launching the application. Details: Failed to execute child process "/home/enowak/proj4a >/home/enowak/proj4a_out" (No such file or directory) I can't for the life of me figure out what is wrong here. Does anybody see what I'm missing?

View 3 Replies View Related

Ubuntu :: Receiving Error When Trying To Run In Administrative Mode "failed To Execute Child Process"

Nov 16, 2010

receiving an error when trying to run in administrative mode "failed to execute child process "amddxdg-su"(no such file or directory. how do i resolve this?

View 1 Replies View Related

Ubuntu :: Sub-process /usr/bin/dpkg Returned An Error Code (1)

Jan 14, 2010

I think that my computer crashed one time, while I was in middle of installing some new software, and it seems like it have made "dpkg" confused with itself - it thinks, that I still need to install "Wine", but it is allready installed, so everything is allright. But everytime, when I am upgrading or installing any kind of software, it give me this error (just an error, everything still works and installs fine):

Setting up wine (1.0.1-0ubuntu8) ...
kernel.printk = 4 4 1 7
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.all.rp_filter = 1


Errors were encountered while processing: wine E: Sub-process /usr/bin/dpkg returned an error code (1)

View 6 Replies View Related

Software :: E: Sub-process /usr/bin/dpkg Returned An Error Code (1)

Jan 30, 2010

I'm trying to customize my BackTrack4 image so I can use the live disk with my ati graphic card. While trying to put the drivers with the apt-get install ati-driver command, I get the following message:

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:


View 2 Replies View Related

Programming :: Stop Reading Process Without Be Hanged At The Code In Python?

Dec 11, 2010

I have a Python program looks like this one :

Code: import os
import time
process = os.popen("top").readlines()


View 2 Replies View Related

Ubuntu Installation :: E: Sub-process /usr/bin/dpkg Returned An Error Code (1)

Mar 13, 2010

Thought I could just place a hard drive with a preloaded Ubuntu install from another machine (a loaner machine) into this one; change a few drivers and be on my way. Too many errors to count. ALSA; Jack; LiveTex all cratered and I'm tired of fighting this. I've spent more than two days trying to get stuff working and if there's anything I've learned from years of experience there's a time to cut bait and run.

A clean install on the actual hardware I'm using has to be better than the hodge podge I have now.What I would like from the community is recommendations for what to do AFTER the install.

1) where can I find the most up-to-date comprehensive and exhaustive list of repositories for the Synaptic Package Manager?

2) I like to do sound and video processing. I would like to have the program applications
Qsynth, Virtual Midi Keyboard, Muse Score, Csound, GNU Denemo, and many others that either fail to start or produce no sound to work. What, besides the programs need to be loaded in order to make these work?

3) A helpful list of recommendations on what to install along with order preference. In other words 'this needs to be done before this...' on a new Ubuntu install.

In case anyone's interested: Here's a small list of some of the errors I currently have.
AlsaModularSynth - Could not open file.Qsynth1 - Failed to create the audio driver (jack) / Jack server not running.

Errors were encountered while processing:

E: Sub-process /usr/bin/dpkg returned an error code (1)

Qtractor - The audio/MIDI engine could not be started. Make sure the JACK audio server (jackd) and/or the ALSA Sequencer kernel module (snd-seq-midi) are up and running and then restart the session.

apt-get install alsa-utils - Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)

Jack configuration files not found; the list is endless. Plus many errors trying to get texlive to work.

View 1 Replies View Related

Ubuntu :: Build Failed - Sub Process Returned Error Code

Sep 24, 2010

The problem emerged when I started to make the internal microphone and external speakers work [URL]. In either kernel 2.6.32-24 or 2.6.35-15 - cannot install any package with apt-get. Here is the error I get when installing just anything [URL]. Basically, here is it:

ERROR: Build failed. Please review the build log at /tmp/alsa-driver-linuxant.3620.log
dpkg: error processing alsa-driver-linuxant (--configure):
subprocess installed post-installation script returned error exit status 2
Setting up libxslt1-dev (1.1.26-1ubuntu1) ...
Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)

View 3 Replies View Related

Ubuntu Servers :: E: Sub-process /usr/bin/dpkg Returned An Error Code (1)

Dec 19, 2010

I have a little home server running server 8.04 and decided to check for upgrades. One of the upgrades was a new kernal update. It was able to download the update, but errors on uncompressing it. I have even shutdown the server and restarted it. Still no luck.

Here is the screen log from the update process:

(Reading database ... 49993 files and directories currently installed.)
Preparing to replace linux-image-2.6.24-28-server 2.6.24-28.80 (using .../linux- image-2.6.24-28-server_2.6.24-28.81_i386.deb) ...
Unpacking replacement linux-image-2.6.24-28-server ...


View 1 Replies View Related

Ubuntu Installation :: E: Sub-process /usr/bin/dpkg Returned An Error Code (2)

Apr 8, 2011

when i try to update using terminal and update manager i get this error

/usr/bin/dpkg: 1: Syntax error: "&" unexpected
E: Sub-process /usr/bin/dpkg returned an error code (2)

View 7 Replies View Related

Copyrights 2005-15, All rights reserved