Skip to content
Advertisement

Tag: process

Kill all processes from C in Linux

I am writing a Linux C program that will be executed as init. It will eventually need to shut down the system. I have code for unmounting all the filesystems and actually turning off the system; now I just need a way for it to send SIGTERM to all processes, sleep(5), then send SIGKILL to any remaining processes. Answer If

Does linux process VSZ equal 0 mean kernel space application?

I notice some process always have VSZ as 0 how to understand why they have 0 VSZ? Answer VSZ is the Virtual Memory Size. It includes all memory that the process can access, including memory that is swapped out, memory that is allocated, but not used, and memory that is from shared libraries. So, the top command screenshot you shared

Changing nice value of a process has no effect in Linux

I read about APUE 3rd, 8.16 Process Scheduling, there is an example written to verify that changing nice value of a process will affect its priority, I rewrite the code like below: And the result of the example is shown below: NZERO = 20 parent nice:20 child nice:20, adjusted by 0 child now nice:20 parent count:601089419 child count:603271014 Looks like

How many ways will a process be terminated in Linux?

I’m reading Advanced Programming in the Unix Environment 3rd Edn, ยง7.3, Process Termination, the following statement make me confused: There are eight ways for a process to terminate. Normal termination occurs in five ways: Return from main Calling exit Calling _exit or _Exit Return of the last thread from its start routine (Section 11.5) Calling pthread_exit (Section 11.5) from the

linux c: what’s the common use case of “sched_setaffinity” function? I don’t find it useful

The operating system is able to determine how to arrange difference processes/threads onto different cpu cores, the os scheduler does the work well. So when do we really need to call functions like sched_setafficity() for a process, or pthread_setaffinity_np() for a pthread? It doesn’t seem to be able to raise any performance dramatically, if it can, then I suppose we

Irregular result in zombie example

I have problems with understanding the behavior of this code: When running in a Unix shell I get this result: But sometimes its only giving me this result without any shell prompt: I know it can be solved with wait() function in parent process. But I like to know: Why is result irregular? Could someone please explain what happening? Child

Advertisement