Skip to content
Snippets Groups Projects
Commit af845ed8 authored by k2-colambatant's avatar k2-colambatant
Browse files

- task2.c contains the code snippet used for task 2.

parent 89416c00
No related branches found
No related tags found
No related merge requests found
//STUDENT ID: 20042129
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
//Access environment variables
extern char **environ;
void printenv()
{
int i = 0;
while (environ[i] != NULL) {
printf("%s\n", environ[i]);
i++;
}
}
void main()
{
pid_t childPid;
switch(childPid = fork()) {
case 0: /* child process */
//printenv(); // (1)
exit(0);
default: /* parent process */
printenv(); //(2)
exit(0);
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment