linuxopensshnice

Run high-priority sshd process without inheriting that priority to child process


I have given highest priority to sshd process using following command:

nice -n -20 /sbin/sshd

But it will give highest priority to child process (/bin/sh) also by default. So, is it possible to give normal priority (0) to child process instead of highest priority?


Solution

  • Its not possible to give normal priority to child process of niced process but we can assign normal priority in parent process code after fork() and before exec() of the child, this way we can assign normal priority to child process.

    Refer setpriority for setting priority for any process from code