What will happen if I kill a process which is waiting for the retuan ioctl() syscall?

Larry Chen lchen at suse.com
Tue Mar 13 23:27:41 EDT 2018


Hello Douglas,

On 03/13/2018 07:56 PM, Douglas Su wrote:
> If I have these:
>
> 1. I have implemented a simple ioctl() system call which just delay a period and return.
> 2. Call this ioctl() from a userspace process, of course, this process will be blocked until ioctl() return.
> 3. Before ioctl() return, use `kill -9 <pid>` command terminates the process.
>
> Question:
>
> 1. Can we instantly kill this process?
Of course, you can. But whether your behavior will affect your process 
depends on your implementation.
> 2. If we can instantly kill this process, does ioctl() still keep delay after killing?
It depends on your implementation of your ioctl.
If your ioctl has some kind of mechanism to check whether there is a 
signal received, you can let your ioctl return.
> 3. If ioctl() still running even after we terminate this process, where does the return value ioctl() will return to?
That sounds insane.
> 4. How to keep the device's state consistent when we kill a process when it is invoking a system call?
Sorry, I did not get your point.

Thanks,
Larry
>
> Best regards.
>
>
>
>
> Douglas
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>




More information about the Kernelnewbies mailing list