Okay, and let's start recording
Okay, good morning. Everyone let's get started so we've got some questions about the assignment.
That's what I mentioned so
So basically for the validator if you if you're getting an error.
It's not accepting it. it should generate some error messages on the screen.
If you don't understand the error messages let me know, and I will.
Oh, I can try translating, and maybe I need to update my script.
So it's clear. It just says error that seems funny
Send your some of your assignment, and i'll take a look just Pm.
Yet, too. so, and i'll let you know carson we will talk about that.
So, Anna. how exactly should we even have the same font as the template?
The template is a text file. It does not have a font.
So you should be using a text editor to you know, to deal with it.
Not so if you're dealing with fonts you're doing something wrong.
Okay, Okay, if it says it doesn't follow the pattern it probably is talking about the questions you're probably missing.
Which question it does not It looking this is not except where Docs definitely not.
It's like looking for unix text files so you should be using a text that are not a word processor.
You can get word to output tax files although they're I don't think they'll be unix text files.
Yeah. text edit should be fine on a Mac notepad actually can work
But I would really suggest something. All programmers should be comfortable with using a text editor, because that's what you should use to generate.
Code, you could use the text that are built into an ide.
But you should have access to textbook. Yeah, no path plus yes.
Vs. code works. Yup: vs. code vim. yeah, that those are all fun.
Now, one thing is, we use text edit on a Mac.
Make sure you do not save it as a rich text file, but save it as a plain text file.
Yeah, you can convert to you extensive. but this So: okay, So okay, So
So there was a more technical question here about Why, we don't see the handler function in 3,000 shell code.
Okay, the handler function that that's
The validator definitely checks for carriage return line feed and it does not like it when it's not character.
Be it it definitely doesn't like that. I thought it has an error message actually tells about that.
Again. Send me the file. I can check, anyway, moving on.
Yeah. So So one thing to keep mind is I understand there's a bit of pain with doing with figure out how to get the format of the assignment right?
But you're gonna use this same format for all the assignments, and for the midterm and final.
So it's good to figure out a good workflow now, because you'll be using it throughout the semester.
And the reason I said for this is because I have programs that split up my question and put them together.
I could make you all use a web app, and you type in your answers there.
But that that just hurts me. So you won't get comfortable using textiles.
Yeah, do you write your Your sources? sources are with each question.
Collaborators is just the top
Okay, So yeah, we got I so I see the question about why Sis calls are able to be called an assembly without any argument.
So let's let's go through a we've got lots of things to go through by this point in the course.
Should you be able to understand all the lines of of code in the tutorials?
You've definitely seen things that you can't We haven't really talked about kernel functionality.
There is a number of things I expect you not to completely understand.
I do expect you to understand everything in the assignment
I expect you to do all these, you know a challenging.
Yeah, So look we're gonna start on tutorial 3 now, i'm happy.
But I'm happy to answer some question if you have questions about the essential about assignment.
One, let me know. but i'm gonna focus now on tutorial 3.
So
Okay, So here we are, my wiki and let's go down to 2, 4 to 3
Oh, we'll definitely yes, you definitely can ask questions about assignment one privately during office hours. You know we're doing after lecture. If you have a high level question.
I could actually talk about it here. will we discuss the cycle one after the submission date definitely? I will go.
I go through the full solutions of both assignments.
I so you so you all can have and and you'll have solutions for that, and everything.
So So what do we got here? we've got 3,000 you know 3,000 shell.
We've got this code here now, running the programs pretty Okay,
So there's one thing important in here is there's a lot of things in here.
Talk about late. i'm gonna bring up the code of 3,000 shell
Okay, we are on the other. I love it last time.
So here we are, with the code don't post solutions until I post solutions because because I'm, because some people might be, for various reasons, might be submitting their assignments later something when I post the solutions that's when
you can freely discuss it, and if you want to post your own solutions for people to look at.
That's fine. But please don't do so before I post in mind because I have my solutions.
So looking at this code here, and the things I want to talk about is thing that we really haven't discussed which has kind of been in the background. is signals specifically you'll note There's this code here
that's doing some stuff with signals and there's this code here dealing with signals.
So what I wanna first talk about is your mental model that you should have with signals.
So
So what is a sigma on a unix or unix-like system?
What is it it's fun like a it's a
It's a short message set to a process
So it's a set no, it's a message that sent to the to a process by the kernel.
So the Kernel: Yeah.
So it's basically a short message it's but really
But really the data isn't exactly sent
So this is where signals are a little weird.
So it's essentially it's you jump to this code.
But you don't do it with an explicit call it just starts running
So it's more like an exception in a higher level language so so is I.
I don't right understand your questions the process in and of itself then,
It's not a process. This is so our single house predefined in libraries the so it's not the kernel.
The kernel literally causes. Yeah.
So so your program is like is so your
So it literally is the process gets interrupted it's it's, you know, gets interrupted.
It has to all of a sudden change to run the function.
That was, you know that's designated as a registered signal handler, When the single handler returns.
Then you continue execution with the wherever you were
Let's see, Yeah, So
Even please include sources because that way we can know where you're getting information.
We're not going to mark off points if you don't do that.
But if you include a source and you give a wrong answer, we might be able to give you some credit if it turns out the source actually was misleading.
But if using a man, page or something then don't bother it's just if you're going to some random weird website or something.
Okay, so do you mean default single handlers so I haven't got no, no, no, i'm not talking about default.
Single handlers. Almost all signals have single handlers sick kill, and 6 do not have single handlers
So there are these 2 signals
So there are defined. So when you say signal handlers releasing functions, they're really
So by default. there's a bunch of signal handlers that are defined by the C.
Library. So your process automatically has those depth that behavior, these mostly just terminate the process.
So is a single the same as the interrupt
Is the Internet point
So hardware has a sil has similar kinds of mechanisms these they're called interrupts.
We will talk about interrupts later, when I talk more about how you know how drivers work and stuff, and how how the kernel functions things.
But signals definitely are implemented in the same. They have the same kind of flavor to them as interrupt handlers.
But signals are a process specific mechanism, and they're but when you lure up in interrupt panels, you'll see that clearly.
Signals were inspired by the design of interrupt handlers, and essentially interrupt handlers for processes as opposed to.
But what that means is is but really don't worry about that for now just think about okay.
When the process gets a signal it starts running the code and then returns back
So basically the Sig. the current address is saved in the stack before the single hands run.
So when you want to return you can just pop it off stock and get back to where you are.
And interrupt is not a type so it's completely separate mechanism complete, something like it.
But it's but it's it's got a similar flavor to it.
So a single use for scheduling by the kernel I direct and process start to stop.
The sign goes wrong. yes. Well, well, partially
Signals are ways to control the execution of processes
Oh, that is not a silly question actually it's not so. so.
A single is not a system call, but a single handler will typically make system calls signal.
I'll talk about concurrency in a second
So note that you could say a single is kind of the opposite of a system call because it's going the other direction instead of the process doing a special instruction that causes the kernel to be run here.
The kernel is doing something to cause the process to run specific code
So it's like possible to like make up your own signal.
No, no, the singles are hard coded by the kernel, but there are certain signals that can be used by my user space program.
Now I'm gonna look so i'm saying 7 signal notice the the man pages have separate sections If I just look up signal.
I'm going to get the man pitch the signal function which is actually something you shouldn't use.
So this is Nc. signal handling. This is actually the old fashioned way of defying a single handler.
But this varies across users also. have very historically what it's used.
You stick action instead. So big warning so that's why we're not using it in our code here.
But So this is what actually I want. This tells you overview signals.
This tells you about all you know. this is got a nice thing.
Does that send a signal different ones? But the thing I want to point out here is this: tells you about what all the signals are, and they're for all kinds of events.
But those things like get a power failure. Quit from keyboard segmentation, violation, invalidate, you know. you know.
Sick bus is also here. So the things you get when you access an invalid, you know, Pointer, those have show up also things that Sig user one.
And you think, user 2, those you can define for whatever process thing you want.
There's no default thing it means wonderful so so the term core.
So what it means is core means dump core so don't so what is dumping core so
So a core dump. That just means you dump the memory wine.
There and then so
Ignore. Yeah, this is anything and
Process an evening. Ignore What if we like what's the process going to ignore exactly ignore means it doesn't do anything?
Is it going to stop listening to any more signals?
Or No, no, ignore it means it just doesn't do anything in response to the sale.
So if you look at the ones that it's doing ignore for so, Sig, child, we're gonna talk about Sig child in a second.
But if you don't do anything for it you're You're fine.
You can just ignore it. very not many, not many signals.
Sig. urgent condition on socket. Psv.
4. do Not that's it that's sick urgent that's about the only ones that are ignored.
Most of them are not ignored. And, Sig, child, we are going to discuss shortly.
So i'm i'm trying to catch up on the you know as a bunch of questions here
Yeah. kill dash out, list
Yeah. kill dash out lists on the signals okay that's true.
Yeah.
Also notice that first segue abort and say alarm in this description.
It wrote abort. And then in this brackets a number that number is significant.
Which W. What are you talking about in the comment? Oh, So whenever you see this number, this is app for the section of the man pages.
So you notice at the top. here it says, signal parentheses 7.
So if you just do, man, and something it comes up in the first.
I think of the man pages originally as being bound ball volumes. and, in fact, you can render man pages with the right options to be this really nice version that'll show up as a pdf And things. that actually you know it's actually very nicely
formatted, but originally man pages were bound books, and they had sections, and the section that doing, like the first section, was for interactive commands.
The second one was for the c reference and stuff.
But then there's other sections and things that kind of go more historic and jumble.
But there. So if you have you could have the same thing in different sections like signal.
There's 2 entries in it there's there's at least 2 section 2 and 6.
7. So when you do a man you can give it a number to say the section you want in and and standard is whenever you refer to something like you know it says Sig.
Action 2. That means you could do man 2 sig action but There's only really one sigma can just do man Sig.
Action. So there's always a convention you'll see these parentheses and numbers.
So if I do raise so raise the single handle so like that's right there, or any I know, it says raise 3 I do 3 raise, and it's the same thing.
So this is all i'm you know you don't know unix was developed long before the web long long before the web.
So the documentation for unix is here everything's there so
And but now, regarding so i'll show why dump core
So think of the it's it's basically an image So your process is received a signal of something bad happening like you've divided by 0, or you've access to invalid memory pointer so by default I think these
are bugs the problem. So if you want to figure out what the hell happened, you want my one to have a core dump, so you would take all of ram of the process, not of the entire computer of the process.
And write it to a file. that file by default is called core because it's for core memory.
If you look up core memory you'll see it's a t type of random access memory.
So you'll have this core dump and you can attach a debugger to it. A.
Gdb. and you can actually look at it. and see the state of memory exactly what was what was going on.
It's almost like a flight recorder or something here's the state of it when it died.
So nowadays, by default, core dumps are often turned off so like, you can set the basically set it. so.
Only so the core dump limit to be 0 so you won't get core dump files.
But you can easily enable that if you want to get a core now.
But I process, you know, crashing. Now, the reason why you want to have this turned off is because otherwise, when processes crash, you have these file call core lying around your file system, they can be rather large.
And so you know, they take up to space. Yeah. R.
Ram and discard are are are in there's lots of connections to you.
Yeah, yeah, yeah, get get get saved to desk to a file called Core I'm trying to think of.
So. Yeah. So you were so you've all up to this point only program, some with the with the signals into tutorial.
So, so concurrency is what we have
So
So when I say an execution context
So an execution context the state of the Cpu, its registers when you
If there's an error in a pro where they're where a single hot is, then invoked that you will put an in 3 instruction a single handler for debugging, there are lots of ways that debuggers
work I don't think you put an in 3 instruction I have to look that up.
But no, you don't you know typically do that least manually a debugger won't change
Our signals used only when something goes wrong no no they're not, and and we'll talk about that in a second here.
But most of the singles are, when thing goes wrong, but definitely put definitely, not all of them.
But so just here, so oh.
So what I mean by single threaded is I mean there's only one execution.
Contact, which means a process, is only doing one thing after the other.
There was no parallel processing happening inside of, you know, parallel probably happening inside of a standard unix process.
A multi-threaded process means that you actually have 2 literally
So So this is a concept, so that multi-threaded programming is how you can have one process make use of multiple cores?
Because ideas, then you literally have you have 2 functions running at the same, 2 or more, depending on how many threads you have 2 or more functions running at the same time, because each of them are potentially running on deaf cores They don't have to
be ring at the same time, but they can be running at the same time on different cores, and they're both.
They're all executing in the same mem address space, which means they can all see a exactly the same memory, all the same variables, everything does that mean they can interfere with each other very much so and so we will talk about how
you keep the same later. This is whole thing called locking and mutual exclusion and stuff which we want. we'll talk about later in the term, but it's a big deal. Signals do not live in such a world.
Signals really were built for a single threaded world.
And so what happens is is the process is just executing one thing after the other, and then the single handler comes in.
It jumps to some other place to run the simulator, and then, when it's done, it jumps back.
But at 1 point your process either running your regular code or it's running the signal animal, it's never running both
So you're either running application code or you're right single have a code.
Those 2 never happen at the same time. Of course, if you add in a multi-threaded pro processes singles, it turns out signals are a mess
Single. If you start ringing up with signals and multi-thread processing, collecting, this is just wow.
So let me see
Yeah, the contents of its registers. Yes, So we use most
I'm just gonna say that multi-threaded processes, I think, is a bad, bad bad idea, and I would advocate you, avoiding using multi-threaded processes wherever possible.
So little rant here, I think multi-threaded multi-threaded process.
I think, is an abomination. he's horrible it just makes no sense.
It's just
We can talk about things like lightweight. threads and about kind of actor model concurrency that there there are stories people can tell about how to do it, but it's better just to have multiple processes and just share the
memory you have, because otherwise, if you share everything, think about you know
Sorry i'll i'll stop talking about threads here but I just need to make sure so different threads are in the same use.
The same address space of the program, but have their own call stacks on that trust space.
It's ricky exactly is this a personal opinion or a widely agreed that multivariate processes are bad.
It is definitely not. depends on where you look. It depends on where you look, But anyone will tell you that multi-threaded programs are very hard to code correctly.
They will all admit that it is a minefield of mistakes and there's lots of ways to get things wrong.
I have not seen as much there's not as much I mean
Fundamentally on windows doing this sort of architecture doesn't work so well, because windows processes are much heavier weight, so have using threads does lead to much better. performance.
That's not the case on linux but of course, if you're trying to port architecture between the 2.
Then people start doing this? it's it's just bad So the advantage of multi-threading.
Yeah, they did have multi-threading. But is that threads can see the same data easier.
Yeah, you don't you get default sharing everything so it's easy to share all the data exactly, but going back to signals.
So let's go back let's look at the code for 3,000 shell.
What's going on here with the signals so first let's walk through Maine first.
What's happening first you've got them set so what this is is I've got a struct here that's I've defined here as a local variable, and so since I defined the very as a local variable it is
just a it's not initialized if you allocate global variables that normally be initialized to 0 things on the stack, because the way the stock is allocated.
They can have all kinds of random crap. so you should always initialize local variables.
And so this is me initializing the local variable here which I'm.
Using up wish using the function, mem. set which i'm just saying it to 0.
This, you're. basically putting zeros into this the size of the ceiling handle is struck. So it's a stupid sea way of doing this.
But then, after I've set it to 0 i'm initializing the struct with a couple of values, one thing I'm putting in here is i'm putting the I know so essay handler is a pointer
2 a type you know to the handler and i'm signed that to signal handler, and then i'm assigned essay flags, I'm.
Saying, essay, i'm just for restart you should try it without this restart one.
It will change how the program games. I think I have some questions about that.
But oh, this is changing! How i'll sing they're being handled, and we will talk about si and start.
But we set flies. We set the handler, and then we call Sig Action and Sig.
Action, says, I want to set a single handler for a specific signal, and the way you do this is you specify the signal you want here.
I'm the same thing, child, and then i'm specifying the address of the single handler struck, which has all the information it means.
And then what's the third field
Okay, old one. Oh, if so, the null is that if I wanted to save the old I may have had some previous signal handling registered, and I wanna know what struck.
That was. I can put put a pointer to a struct here, and it will fill in the cold signal handle or state here.
Before I replace it with a new one I don't care at this point, so I just put it to null and it does that, and then I it returns if it doesn't return 0 that it failed and then
I promote narrow same thing I do for Singh Hu.
And so the same function, the same single handler. I design to handle both signals.
So what is So the you know, the only really interesting thing in the struct is the function signal handler.
And this is the function. now you'll notice this is has to be. how the single handler function is declared.
It has one parameter, which is an int, which is the single that was received, and it returns nothing.
This is required by If you look at the Sig action, man Page, we can see.
But this is here at in the Sig action. we is signal handler.
We have a function pointer here which points to a function that takes an int as an argument and returns a board.
You know so that is that's the declaration right here and
And so we you know this function. Then chucks when you know what single was received and does the right thing based on that, we'll talk about those actions.
There, but no notice that in our code we never explicitly call the function single handler.
We do not run it so. how does it run? You know.
How, how does How does the single handle run? It runs
Because the kernel made it run. You might go like, how can the kernel make a process run things?
Because the process, the kernel controls all it's literally messing with the memory of the process, and the kernel created it all so it can mess with anything at once.
And Larry can say, Oh, yeah, you're running this now I mean it could have just over written all its memory could have done it.
But instead it's just changed it so that you're gonna run this code next.
And so it does, but it's not an explicit call it's literally the Colonel.
The Colonel is who called this. the Colonel did. Yes, the single yeah.
And and then Sigma is the simple one. exactly.
E is much more invasive. It kind of completely, completely rewrites the process.
Memory will change the memory, pull it so a little bit
Is there a tip on? How you would know that the kernel would call The way you know that the kernel is going to call this function is because it's in the signal handler struck, and we registered as
a single handler that's why it's being called That's the only reason why it's being called
Are there any commands in the shell you can use?
Is the single handle run in user space. This is a signal handler.
Is the code in this process? user space? Yes. So so this is.
This is a single handle. it's part of the process so it is definitely user space. are there any commands and shell? We can use the treatless single handlers.
So when you
Yeah kill every time you hit control, c. you generate a sig, I think.
Interrupt segments let's see
Second. Yes, so interrupt for a keyboard. So if you hit control Cna process to stop it, you are sending the signal to the process control.
D control these a bit different. control d causes the terminal to send end of file on the on the terminal, so it's not It's it's more it's more causing the charter giant and
the file. it's not sending it a signal but control c.
Is definitely interrupting things and control Z also does, which causes a sig stop so
So if I do so let's see now so if I do ls.
I I do talk. I hit control, c it does nothing Oh, I guess 2 criminal C's work.
Okay, if I hit and I hit control Z. I get stopped and stop means it's interrupted.
It's still there, and I can type foreground percent one. So that tells me, resume, put, bring to this the the job in the background there, and Top continues running. exactly.
So if I hit control, c. that's terminated I mean i'm, hitting control, c.
Twice, because Emac is interrupting the first control scene. But
I could test on a terminal, but i'm control sees terminating it.
It's saying, interrupting top is you know quitting nicely versus control Z.
It's stopping and then you're not to resume it
So what do I i'll let go back to this Co.
Here, so sig, hop.
Can we? Can we unposit some out this? Yes, you can.
You have to just bring it to the foreground. that's Why, I just showed you how to do it.
Did you see it out like when I unpause top?
I just did that just now
So so i'll just i'll see you one more time so I do Top.
I get control. Z. you see I get this message stopped and then so this could, you know, so I could just hit foreground as well. If I do hit foreground.
It'll do the last stop process I can just find the job with percent.
And the number of the jobs. Yeah, this the square bracket one.
That is the job number. so like I could do another top.
I control Z, I could do another top control. z I can type jobs, and I can see I have 3 tops running, and so I need it foreground, and I can queue.
I'm gonna jobs. Now i've got 2 I can do I know how I could get 4 ground percent.
One to do the first one with that one percent 2.
No jobs. 25 background. Is there a way to kill all stop processes?
You normally have to kill them off one at a time because and that's why you have to specify the either by process, Id or by job number
So so I can do or let's try doing that I can try
So here is this, though 2 plus 2. so I can do this.
I can say background percent one. But then, if I do, if I do this, it says stopped.
Why have I? Why is it? say stopped it's because it wants input from the terminal and the show has it.
And so Bc. is not getting it. So if you want to have it, have input, you need to say foreground.
And now and now it's back and I hit control d and i'm into that. So i've given an end to file so background only really makes sense.
If it's not trying to interact with the terminal if it's like reading and writing to files
Yeah. The reads Cisco is blocking, which make it was stopped.
Yes, exactly tried reading It didn't get anything and so it stopped exactly
So Sig hop is just a signal that's used qu traditionally, when a modem hangs out so your remote Ssh!
Connection. if you kill your window. if if you're logged in remotely via ssh to your Vm.
And you kill your window. So the Ssh. process locally terminates what happens on the remote side.
The Ssh. a demon process should get a sig hop from the remote connection.
Quite sure but that's traditionally what should receive because there was a hangup on a remote connection, and so then it can say, Oh, I should probably shut down because no one's listening to me.
I can't I can't interact with my so we we just now we're we're basically ignoring sick hop because the default
For Sig hot is terminate so normally a process when it gets a sign up terminates.
But 3,000 shell does not terminate and Instead, just prints a message saying, Receive Singap, that's what that's what it means to change the signal handlers. We can change how it behaves in response these
signals, and then the description for Sick Hub was pretty dark description, for Sikh was pretty dark, was pretty dark.
Yeah, in the comments. Oh.
Oh, I I I didn't I didn't see that but i'm i'm not sure. but anyway, or or death of controlling process.
We talk about. well, I haven't mentioned I I'll, i'll talk about this in this.
But So sig child, is set when a child process is terminated.
So we're doing fork
So this is a little silly part of of unix terminology is that if a parent does not handle the death of its children, you get zombies.
Now, what is a zombie
So this is all kind of weird Terminology, But if you kill a process so winning.
It's no source they're corrupted so it comes down to Apis.
So
So all like zombie processes, is a placeholder for the return value of a process.
So you know, when you, when we have Maine, Maine, has this return value.
Int who gets the end when main exits, who gets it is the parent process.
And so when we we call, wait
So if you call an exit system, call directly or main returns.
You have a return value of some kind it's a number someone has to get that number that is the parent, and so the way the parent
So notice what we do here in the single handler is, if the Sig child is here, we said, we child can call the note childhand.
Were called. They go. So this code here see how we just return immediately.
So this rest of this code is not run if it's not Sig, child.
Then it's some other signal we don't know how to handle it.
And we're confused about it but here at this point we can assume that we receive a sig child signal, and so we must handle it, and the way we handle it is by calling rate, and we give it the address of the
status int, and we have the pid. So what this does is what process guide, and with what status, and those are 2 integers.
And so the process is, says if we got Pid minus one there was nothing to wait for.
There was no child there. And so we just returned and here. This is a little macro that we use for checking the status, and this we say that if it exited, you know the status because it turns out there's actually 2
values encoded in that number. There is the thing of what the status was, and the return value.
They're actually both in one end and so we have to extract those out.
And these are the little things for extracting it. And this says: If if it exited, then we say that the process exited with the status and this, and we tell the process number, and we tell it the status that it exited
with, but otherwise, the Process If we don't get this it's something else happened to it, probably a boarded.
So it didn't actually return for maine it might have gotten killed some other way.
And so then we'll say process to your border so was there a a question that was someone
So play. So if you don't do this if you if a process just doesn't have a single handler for sick child, or hasn't called weight in some other way, the process can happily keep running along.
But there will, you know, but the weight values. but the status return status values of those processes that it made.
Children will stick around as long as there's as long as the parent is around, and you'll see them in the process table with the z status.
No, there's no you have to call wait there's wait and there's Weight pid those the only 2 things you gotta call one of them.
Oh, what if I say printf instead of F printf
Yeah, yeah, yeah, definitely, wait. almost. so. the reason why i'm saying printf after printf standard error.
Is because I want to write to standard error. not stand it out.
We'll talk about standard file descriptors more later, but that's all.
It is right now. So you
So, if a process
So does sorry process will disappear. If you do wait and get to return valiant.
Well, the if the process is terminated that will remove it from the process table, so no longer show up on Ps.
But is is the zombie But and and literally if you look at the status of the process, you'll actually see a zoom in the process table for its status.
Okay, Yeah. So I i'm just I mean i'm just about to discuss this right now.
Your question. so So they'll stick her off the light to the parent process
So there's process number one has special semantics and we'll we'll talk about that later.
But it's there is a process that will become the parent of any one orphans.
So if you're p If your parents die the child's still around it has to have a parent.
It always has to be a valid parent for every process.
The only process that is weird like that is process number one it's its own parent.
Because it's the root of the tree. but other than that, every process has to have a parent.
So if you get, if a parent process dies and its children are still around, those have to move up and be parented by someone else, and that parent
So what's what's their have a new parent that new parent will call weight.
It'll get for some value it'll basically throw it away.
But then the kernel can say no one. I I have gotten rid of the return value.
I can get rid of this now.
Instead of reparant. I like adopt yeah that's probably a better term.
Oh!
Yeah, we are. Yeah, yeah. Is it possible to revive a zombie process?
No, because it's exit in maine Okay, Yeah, zombie pro.
If you have a zombie process, it takes up some memory.
The bigger problem is, it takes up a slot in the process table, and normally there's a finite number of Oh, processing that you created a system.
So if you create too many zombie, a couple zombies are not a big issue.
It typically just means you have some badly written code somewhere.
That is a calling weight when I should but if you get a whole bunch of zombies you could actually make it. so you can't create any new process because you don't have a finite number of them.
But how do you handle multiple child processes? So
One thing I will note about * shell is it's doing one thing that is kind of bad it's having print apps, you know.
App printfs in a signal handler you really shouldn't do that
It's. not the it's not the process Id it's the status of the status of the zombie processes Z.
The process. Id is the process Id that doesn't change yeah they'll.
They'll still have the same. Id there's up the th the The pid is always the same as it was before process.
Ids do not change when we talk about the z we're talking about the status.
I'll let me show you what i'm talking my status
So when you look here at this, there is this so here we've got a process Id here.
You got the username you've got the no priority There's a lot of these fields here.
We haven't discussed yet. But look at this field here this s this s right here. can you?
You can see my mouse cursor, Right? Okay. Good.
So. So this this s right. here is the status column, and those most of these we have I.
R S. or something if I had A. I think I means interrupt status a lot of these are for kernel things.
They have weird things, but most of these are S. is stopped. R.
Is for running. If you had a Z. that if you had a zombie it would show up as a Z.
In this column
So if you ran a command, bash in the background and killed Bash before the command finishes.
You would get adopted by pid one It depends if you're running it from a shell.
The shell will normally call Sig child. I mean we'll call wait in response to sick child.
So you have to set things up so that the parent you have to have a process that creates children that isn't calling weight.
That's the only way you can get zombies so otherwise they get read very quickly.
So so the way you can make the way you can make let's see if I can make some zombies here.
Oh!
Okay, so let's i'll just so it's let's make it
So what i'm going to do now, is i'm going to just i'm gonna trick 3,000 shell and i'm going to get rid of it single handlers for sick child.
We're just going to
So i'm going to
Yeah, that should work. Okay, let's do a
1,000, so that's no
I'm just your team Now, Okay, so now, we've got this we type Ls:
And we'll keep the shell here so let's do
So I think
Yes, great. So you see right here. so I ran those processes in the background, and you notice how i've got These default
You know it says this default. that means that these are zombies, and you see other status as Z.
And that's because they are children of this but now notice if I type exit.
So i've now you know done this I exit out 3,000 shell
It's not there. we've gotten rid of it because since 3 h in the shell exited parent of 3,000 shell was bash bash has a working signal handler for sig child.
So it clean things up. that's right so I see that back I don't think Bash got it you know Bash wouldn't have gotten it.
Another process that probably the top of my session, which is probably yeah.
I will not explain that something into light Yeah, so it's like in it, like something like process one handle.
But
Okay, so So this is the stuff you should play with in the tutorial.
You should see stuff like this. you should be able to create zombies pretty easily. If you just mess up the code a 3,000 shell
Oh, I because I passed it to grap i the the I.
If you look at what I did I didn't just run Ps.
I'm sorry Iran Ps and I added I pointed I did it to grab Ls.
So I just searched the output of this for the the string ls.
You know, and that's why I got post audio because It's Ls.
And they got Ls here from tools calls. And now you got Rep.
Ls: because Ls was in that command line. So, hey, this is I was just searching through it.
So 3,000. She was still running before, and in fact, these would not exist.
Running, and i'm just about out of time I don't think I have anything to cover the next 2 or 3 min.
So I will wrap up here i'm trying to think of
Oh, so
Remember assign one is due to Mars makes you tutorials.
You have graded by the end of tomorrow.
Yes, I wanted to just paste the link in there, but put it with the with the question, not the thing also.
I'm not sure what specific formatting you would do other than putting in a link.
Yeah, I mean, you could put a bibliographic form of things. But no, no, no!
But I just need a link that's perfectly fine but again, for collaborators.
Just put it at the top. for the questions you put in the links.
Okay, so I will stop here, and I will stick around, and I have office hours now.
So I will stick around you for a couple of minutes and then i'll switch to my