Solved

Unix system calls

Posted on 2003-10-21
3
275 Views
Last Modified: 2013-12-26
Hi,

Wonder if anyone can help me out with this.

Using fork(), execlp() and wait() only, how may I write a function in a C program that simulates the shell AND-list behaviour.
And how may I return the exit status of the last shell command executed from this function?

Any clue?
Thanks in advance.
0
Comment
Question by:capricious
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 10

Expert Comment

by:Sys_Prog
ID: 9596693
Hi capricious,

I am sorry but I did not get you

BAsically what feature are u talking abt by saying " the shell AND-list behaviour."



0
 

Author Comment

by:capricious
ID: 9598076
oh, AND-list basically means

$ date && date && ls

and the output prints out the value of 'date', ignoring the rest of the list since date returns 0 as its exit status.

I would like to restrict myself to using the 3 system calls fork(), execlp() and wait() to simulate the AND-list behaviour in a C program. Is this possible?

Thanks for any advice..
0
 
LVL 10

Accepted Solution

by:
Sys_Prog earned 50 total points
ID: 9598323
Yes, definitely,

U can use the status parameter in wait() for some particular value which u specify while exiting from child

In child, u can either use a return statement at the end for passing a value OR u can use a exit ( value )

Have a look at the help of wait OR waitpid

Here is one of the links

http://man.he.net/man2/waitpid



 

0

Featured Post

Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question