1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2008
    Rep Power

    Help needed Cprogramming

    i'm new to unixI want to create a c program that would have 3 processes where x is the parent of the other two y and z..
    x would display the kernel release, processor type and OS, while y displays the current directory sorted in reverse order and z prints the current working directiry..
    how do i put unix commands into c programs
    #include <stdio.h>
    #include <stdlib.h>
    #include <unistd.h>
    int main(int argc, char *argv[])
    int val, val2;
    val = fork();
    if (val > 0) {
    printf("parent: val: %d pid: %d\n", val, getpid());
    else if (val == 0) {
    printf("child: val: %d pid: %d\n", val, getpid());
    val2 = fork();
    if (val2 == 0){
    printf("grandchild: val %d pid: %d\n", val, getpid());
    thats what ive come up with, i'm stuck with how to insert the unix commands into the program..pls help
  2. #2
  3. Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2006
    Rep Power
    I'd suspect (not knowing C) you'd want to look at the various exec functions
    The moon on the one hand, the dawn on the other:
    The moon is my sister, the dawn is my brother.
    The moon on my left and the dawn on my right.
    My brother, good morning: my sister, good night.
    -- Hilaire Belloc

IMN logo majestic logo threadwatch logo seochat tools logo