Solved

Unix system calls

Posted on 2003-10-21
3
274 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

728 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