Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .vscode/ipch/25d956c245f8cf55/COMMANDLINE.ipch
Binary file not shown.
Binary file added .vscode/ipch/25d956c245f8cf55/mmap_address.bin
Binary file not shown.
Binary file added .vscode/ipch/2a9c1fe4967559c9/mmap_address.bin
Binary file not shown.
Binary file added .vscode/ipch/46430b4fdbcac4a5/LSLS.ipch
Binary file not shown.
Binary file added .vscode/ipch/46430b4fdbcac4a5/mmap_address.bin
Binary file not shown.
10 changes: 7 additions & 3 deletions ANSWERS.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
**1. List all of the main states a process may be in at any point in time on a standard Unix system. Briefly explain what each of these states means.**
Running - when a process is currently running it is in this state.
Waiting - The process is waiting for something like an event to call it or for resource.
Stopped - The process has been stopped through an exit or killed
Zombie - The process has stopped but has not been removed as it still needs to pass on it's exit status.



**2. What is a zombie process?**

As mentioned above, a zombie process is a process that has exited or is dead but still has data that it needs to pass on. Basically if a process dies with the exit code of 2 but the parent does not recieve it, this process will hold on to that exit code until the parent can pick it up.


**3. How does a zombie process get created? How does one get destroyed?**

When the parent finally reads all of the exit statuses through a wait method, it will see what child processes have died and taker thier exit codes and remove them. you can also manually kill the zombies with the unix command kill -s SIGCHILD <pid> (replacing pid with the id of the parent process).


**4. What are some of the benefits of working in a compiled language versus a non-compiled language? More specifically, what benefits are there to be had from taking the extra time to compile our code?**

A compiled language can catch bugs long before reaching production as it will not allow bad behavior in the code. It will stop things like missing arguments, improper use of variables, data types, spelling, and pointers. This can be benificial as it will allow you to be more confident in the code you have written overall.
Binary file added lsls/lsls
Binary file not shown.
40 changes: 40 additions & 0 deletions lsls/lsls.c
Original file line number Diff line number Diff line change
@@ -1,18 +1,58 @@
#include <stdio.h>
#include <dirent.h>
#include <sys/stat.h>

/**
* Main
*/
int main(int argc, char **argv)
{
// Parse command line
char *dir_name;
DIR *od;
struct dirent *enter;
struct stat fileStat;

// Open directory

// check if no input
if (argc <= 1)
{
// print current directory
dir_name = ".";
}
// if directory in input (argv[1]), make a ref to it
else if (argc == 2)
{
dir_name = argv[1];
}
// catch any errors or incorrect directories
else
{
printf("Cannot open dir '%s'!!", argv[1]);
}

// Open directory

od = opendir(dir_name);

// Repeatly read and print entries
while ((enter = readdir(od)) != NULL)
{
stat(enter->d_name, &fileStat);

if (fileStat.st_mode & S_IFDIR)
{
printf("%s\n", enter->d_name);
}
else
{
printf("size: %ldkb\t file: %s\n", fileStat.st_size, enter->d_name);
}
}

// Close directory
closedir(od);

return 0;
}