C++ :: Executing A Child Process?

Oct 11, 2012

how I can run this as a separate process from the parent program, like a child process,

and return the result back to the parent program.

this script is as follows.

if file "/Stuff/s" exists then continue to run, if file "/Stuff/t" exists, then print "started" if file "/Stuff/t" does not exists, then print "stopped"

if file "/Stuff/s" does not exist then print "quit" and then quit.

Code:
void controlxmmscheck( ) {
if( access( "/Stuff/s", F_OK ) != -1 ) {
xmmscheck
} else {

[Code]....

View 1 Replies


ADVERTISEMENT

C++ :: Give Output To Child Process

Apr 15, 2012

I'm trying to build a basic shell for Unix. This is the code I use to create a new process:

Code:
pid = fork();
if (pid == 0) {
setpgrp();
complexCommand(argv, isComplex);

[code] .....

Where complexCommand is a function that handles the command (uses execvp after generating the correct string out of argv). My problem is that after if while in the shell I use a program that needs to print to the screen and handle input, it doesn't work as expected. To test this, I built this small program:

Code:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int main() {
int x1, x2;

[code] ....

And when I use the shell I built to run it, the output is only "Enter 2 numbers" for one time. It doesn't print the result, or anything else. Is there anything I need to do in the parent process (my shell in this case) to give the child the output?

View 2 Replies View Related

C++ :: Writing To 2D Array Of Pipes In Child Process

Apr 15, 2014

I am writing a program that is supposed to open a directory as a command line argument, read that directory, open each file and count a number of occurrences of a certain character, taken from the user as cin, fork the parent process to create a child process for each file. a pipe is created for communication with the parent and a 2 dimensional array of pipes is needed for communication with each child process (each file), one for the pipe number and the other is the read/write descriptor(0 or 1). My program is looping through all the files ok, but it seems it isn't writing the "char a" to the pipe correctly. f

For every child, do_child_stuff() is called, and it reads the file name, opens it, counts the # of occurrences and returns that count to the parent to hold a total for all the files. normally to write to a pipe, it should be write(pipe_name[1], &a, sizeof(a)) but I don't know how to do this with an array of pipes. i try to write to it by doing write(child_pipe[pc][1], &a...) pc is the array position for that pipe and it gets incremented after reading each file.

struct dirent *d;
struct stat sb;
int adult_pipe[2];
int child_pipes[1000][2];

[Code]....

View 5 Replies View Related

C :: Create 9 Child Processes And Eventually Write From Each Process To Another?

Nov 18, 2013

I want to create 9 child processes and eventually write from each process to another. How can I specifically create 9 child processes and leave them running? Right now, I am using a loop from i=0 to i=8 and running fork() within that loop, but each child process also runs the loop, which spawns dozens (maybe hundreds?) of processes. I specifically only want to create nine of them. How can I do this?

Code:
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>

[Code].....

View 7 Replies View Related

C++ :: Makefile Only Executing First Entry

Mar 15, 2013

Why this makefile only executes the first entry, compiling only the first program listed?

###########################################################
#
# Simple Makefile for Operating Systems Project 2
#
###########################################################
vowcon:
g++ -o vowcon vowcon.cpp -pthread
osproj2c:
g++ -o osproj2c osproj2c.cpp -pthread
osproj2b:
g++ -o osproj2b osproj2b.cpp -pthread
osproj2a:
gcc -o osproj2a osproj2a.c -pthread
clean:
rm osproj2a osproj2b osproj2c osproj2d vowcon

View 7 Replies View Related

C++ :: Function Not Executing Cin-statement?

Oct 16, 2012

I have this problem for an assignment, and one of the functions that I created for it is nothing fancy; just a function that'll take in a number and error-check to make sure the input is valid. However, after doing it, when the program calls that function, it skips the cin statement and ends the program, without letting the user input his number. The function in question is called getSubLength.

Code:
#include <iostream>
#include <string>
#include <iomanip>
#include <cstdlib>
using namespace std;
const string JANUARY = "January";

[code]...

View 2 Replies View Related

C++ :: Pointer Pointing To Null Still Executing

Dec 9, 2013

in the below program for both class pointers pointing to null. Class contains normal function executing but class contains virtual function getting segmentation fault.

#include <cstdio>
using namespace std;
class A
{

[Code].....

View 1 Replies View Related

C++ :: Executing Multiple Functions In Program

Mar 24, 2013

We have been assigned to create a program that uses multiple functions. The professor has given us code for two of the functions, one to open a file and then another one to read the files contents and output them. I have put these into my program but they will not execute. The program does run, but the functions themselves are not executing. I have practiced with other functions that contain no parameters and those run fine, but the functions she gave us have multiple parameters.

The code I have so far is below:

#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
void PrintFile (string FileName, ifstream& inFile);
int main () {
ifstream inFile;
string fileName;

[Code] .....

View 1 Replies View Related

C/C++ :: How To Keep Console From Closing When Executing Code

Mar 4, 2015

I tried.

cin.get();
and
return 0;

is there a better way to keep the user info displaying without closing the console window.

View 1 Replies View Related

Visual C++ :: How To Stop Executing Constructor

Jun 15, 2013

PHP Code:

using namespace System;
ref class A {
public:
    A(){Console::WriteLine(L"A constructor");}
    virtual void func(){foo();}
    void foo()

[Code] .....

Supposing that class A is the development code; and so for unit-testing purpose I create a mock for it. But I don't know how to override A's constructor such that it will not get executed in my unit-test code.

View 1 Replies View Related

C++ :: Code Stops Executing After GetScores Function

Nov 11, 2014

I am currently working on a c++ project that will input students and process their grades. I encountered a problem and my code stops executing after the getScores function. Im not sure what the problem is, but im guessing its something within the function and the loops.

//Name: getScores
//Description: Will get scores for student
//Parameters: None
//Return: testScore
double getScores()

[code]....

View 6 Replies View Related

C++ :: Play Audio File As Background While Executing Other Operations

Jun 6, 2013

I need to make a program which can play a audio file as background while executing other operations .

View 4 Replies View Related

C Sharp :: Windows Form Not Displaying When Program Is Executing

Apr 9, 2013

I have a Windows form application which has database and will store user details. my problem is while executing program form is not displaying .

View 1 Replies View Related

C++ :: Tell A Program To Continue Executing Next Line Of Code Within Nested IF Statement?

Nov 25, 2013

Is there a way to tell the program to continue reading the next line of code within a nested IF statement?

The reason I want to do this is because the two "else" statements in the following sample (the main and the nested else) will contain the same exact code and I don't want to repeat it twice. I know I can do this by creating a function and calling it from each else statement but I was just wondering if what I'm asking is even possible without using a function.

if(1 < 2) {
// yes 1 is less than 2
if(5 > 10) {
// do something
} else {
// no, 5 in not greater than 10
// here is where I want to tell the program to continue reading the next else statement

[Code] ....

View 8 Replies View Related

C# :: How To Add A Child Row To A Table

Aug 1, 2014

I have a table in which data is populated via an element. However some elements can have a parent element

The client now wants all the children and parent elements to be next to each other row wise.

How can i add the child rows under the parent rows?

parents
foreach (var inspection in elemInspections) {
var date = db.INSPEVNT.Find(db.INSPEVNT.INSPKEY == inspection.INSPKEY && db.INSPEVNT.BRKEY == m_sBrKey);
var paircode = db.PON_ELEM_DEFS.Find(db.PON_ELEM_DEFS.ELEM_KEY == inspection.ELEM_KEY);

[Code] .....

how can i make it so the children go under the parent rows?

View 2 Replies View Related

C :: Pipes Between Child Processes

May 5, 2014

I wrote a C program that is supposed to create a certain number of child processes, each child process having to change 1 letter from a string. The string and the number of child processes are read from the keyboard. I want to do it using pipes.

It should work like this: The parent changes one letter, then the first child takes the string modified by the parent and changes one more letter. The second child takes the string modified by the first one (2 letters are already changed) and changes one more and so on. I am new to C and am not quite sure how it all works, especially pipes. Also can the children be linked between them through the pipe, or can they only be linked to the parent and it has to be something like: first child changes a letter, gives the string back to the parent and then the second child reads from there, modifies letter and gives back.

If it's like that, is there any way to make sure that this doesn't happen: Apples becomes AppleD and then AppleX and then AppleQ? For example:

Code:
Input: Apples
Output: Applex Appldx Aqpldx My problem is: I don't get any output from the children.

Here's my code:

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

[Code] .....

View 2 Replies View Related

C++ :: Size Of Object Of Class Child?

Feb 5, 2014

hiclass Parent {
};
class Child : virtual public Parent {
};

What is the size of object of Class Child in following case?

View 17 Replies View Related

C# :: How To Allow TreeView To Have Child Nodes Of Different UI Types

Jul 14, 2014

Right now I'm working on a TreeView for which I would like to add a TextBlock and a ComboBox as child nodes of a Parent TextBlock node. This would look something like this:

My TreeView is implemented using an MVVM style, and utilizes a HierarchicalDataTemplate. I have had no problems with adding TextBlock nodes and TextBlock children, but the confusion seems to arise when adding child nodes of different UI types.

I have tried implementing a stackPanel, like so:

<HierarchicalDataTemplate DataType="{x:Type Data:Node}" ItemsSource="{Binding Teams}">
<StackPanel>
<TextBlock Text="{Binding IndividualProperty}" />
<ComboBox ItemsSource="{Binding CollectionProperty}" />
</StackPanel>
</HierarchicalDataTemplate>

But then I end up with each node looking like this. It's like each node comes with one TextBlock and a ComboBox (Note: The comboBox is not the child, it and the TextBlock are one node):

How do I allow my treeView to have child nodes of different UI types? I am thinking that my solution has to do with my Hierarchical Data Template.

View 4 Replies View Related

C/C++ :: How To Create Single Instance Of Child Exe

Nov 13, 2013

I have an MFC application(.exe) in which i am creating an pointer object to CComQIptr<chemst::IChems>myinfo and after this i have using cocreate instance i had created the object launching that object, so Where i am using that CComQIptr object.

I have been creating instance to that COM exe (child exe) and at the end of the function i am releasing that object (myinfo->release).i want to create single instance for it and i want to use them in different .cpp files and finally i want to kill the child exe. Even though i release the object it is still alive.(Visualising in Task manager whether the exe is still alive or not).

View 1 Replies View Related

C++ :: Deleting Node (With Two Child) In Trees

Sep 20, 2013

I have Problems with deleting node in trees!my first problem is I don't understand the algorithm of deleting a node with two child! I write some kind of code that delete a node with two child but I think (maybe I should say I am sure ) that it has runtime or logical errors or something like that!

My second problem is my code doesn't work if my node is root of tree!because I don't know if it is root what should be the parentPtr in my code! I set parentPtr to NULL in this situation but I know it is wrong!

Here is my Code :

#include <iostream>
#include "TreeNode.h"
using namespace std;
template<typename NODETYPE> class Tree {
public:
Tree();
void insertNode(const NODETYPE &);

[Code] .....

View 3 Replies View Related

C++ :: Function Overloading In Child Class?

Jan 17, 2014

I am facing some problems while overloading base class functoin in child class. I have 2 programs as listed below.

Program 1 :

#include <iostream>
using namespace std;
class base
{

[Code].....

Compilation Errors:

child_overload.cpp: In function "int main()":
child_overload.cpp:27: error: no matching function for call to "child::func(const char [16])"
child_overload.cpp:17: note: candidates are: void child::func(double)

I thought as base class members are also as part of child class through "public" access specifier, it should access base class function, when funct() is called with a string. if I use "using base::func" in child, it works fine. But why I need that when base class memebers are part of child class?

View 2 Replies View Related

Visual C++ :: How To Create MDI Child With Borders

Jan 7, 2013

How can I create MS Word 'print layout' like interface. The attached picture says it all. Basically I want a shaded area around my document just like word so it gives a feel of the 'page'.

I was hoping I can override some function somewhere and along that lines tried playing around with below but that didn't work.

Code:
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) {
if( !CFrameWndEx::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
cs.cx = 250; // just playing around with size
cs.cy = 250;
return TRUE;
}

How can I do that?

View 6 Replies View Related

Visual C++ :: Child Window On Top Of Control

Nov 30, 2014

I have a child window above an edit control.

When the position of the control in the parent in the child on top of it is clicked the control gets topmost. Is there any way to prevent this?

View 3 Replies View Related

Visual C++ :: MFC Child Windows Application

Nov 9, 2013

I am new in Visual C++ and I have to make an MFC application with "child" windows. Here is what i need to achieve - [URL] ..... As you can observe when you click on the cross of popup window or child window 2 both are closing.

View 2 Replies View Related

C :: Code That Will Store PID Numbers Of Child After A Fork?

Aug 8, 2013

I am currently trying to write a code that will store PID numbers of a child after a fork, I have to be able to enter an amount that will be created, so far I have managed to be able to get them to print (which puts me on the right path as far as I am concerned) but I am having issues. Using the following code:

Code:

#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>

[Code].....

View 3 Replies View Related

C++ :: Reflect Child Classes From Base Class

Nov 26, 2013

We want a solution in C++ that must be able to do the following:

Given a string of particular type, lets say 'A', we want to find all the types that derives from 'A'.

Instantiate new objects out of the types that are derived from 'A'.

E.g. Lets say we have a class, VehicleEntity. VehicleEntityhas child classes, PassangerCarEntity, TruckEntity, TrainEntity, BoatEntity.

We are unsure what vehicle entities there may be as the a library could be added containing more VehicleEntities. E.g. an AirplaneEntity thaterives from VehicleEntity could be added after deployment.

In the application, when a user wants to select a VehicleEntity, the user should be able to pick any of the entities deriving from VehicleEntity. This includes the PassangerCarEntity, TruckEntity, TrainEntity, BoatEntity and AirplaneEntity. The user selects an Entity, lets say AirplaneEntity, A new object of type AirplaneEntity must be instantiated.

The following is an concept example in C# of what we want to achieve in C++.

In C# the items for the dropdown list can be retrieved as follows:

Type vehicleEntityType = typeof(VehicleEntity);
List<Type> types = new List<Type>();
foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())

[Code] .....

We are aware that standard C++ does not contain any Metadata on its objects, and thus it is not possible without a workaround. It does not seem possible with RTTI and boost.Mirror.

View 7 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved