What does kernel do when it receives the SIGKILL - Linux

This is a discussion on What does kernel do when it receives the SIGKILL - Linux ; Hi, As I know, SIGKILL is performed by linux kernel that kill the app, what I want to know is if the app is terminated, the opened file will be closed by kernel? Which file/line implements this? Thanks a lot. ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: What does kernel do when it receives the SIGKILL

  1. What does kernel do when it receives the SIGKILL

    Hi,

    As I know, SIGKILL is performed by linux kernel that kill the app, what
    I want to know is if the app is terminated, the opened file will be
    closed by kernel? Which file/line implements this?

    Thanks a lot.

    ABAI


  2. Re: What does kernel do when it receives the SIGKILL

    Binary wrote:
    > Hi,
    >
    > As I know, SIGKILL is performed by linux kernel that kill the app, what
    > I want to know is if the app is terminated, the opened file will be
    > closed by kernel? Which file/line implements this?


    It's in the exit.c file

    --
    Josef Möllers (Pinguinpfleger bei FSC)
    If failure had no penalty success would not be a prize
    -- T. Pratchett


  3. Re: What does kernel do when it receives the SIGKILL

    Binary wrote:
    > Hi,
    >
    > As I know, SIGKILL is performed by linux kernel that kill the app, what
    > I want to know is if the app is terminated, the opened file will be
    > closed by kernel?


    If that were not the case, there would be a resource leak every time a
    process was killed.

    A file being open means that there is a file descriptor object in
    memory which is associated with that file. To close a file essentially
    means to discard that file descriptor object.

    If a file is deleted while one or more descriptors reference it, it
    continues to exist until the last close, even though no directory entry
    references it. So if process termination failed to close files, not
    only would it result in a resource leak in memory, it would also cause
    resource leaks on disk, which would only be hunted down at the next
    file system check (fsck).


+ Reply to Thread