Operation Not Permitted Error When Killing Linux Process from LabVIEW

Updated Dec 5, 2019

Reported In

Software

  • LabVIEW

Operating System

  • NI Linux Real-Time

Other


 

Issue Details

We have a cRIO connected to hardware over Ethernet, with a driver in the form of a Linux binary. From LabVIEW, we need to launch this driver, and kill it programatically.
We can get the application process number using “ps –a | grep [application name]”, and run “kill [process number]”.
When doing this with System Exec, it returns an error, saying “\bin\sh:line0:kill:[process number] – Operation Not Permitted”.

Solution

The main method LabVIEW has for issuing commands to an operating system is the System Exec VI.
Linux decides what permissions commands and processes have based on the permissions of the user who created them. Any commands originating in LabVIEW are associated with the user lvuser.


This error occurs when lvuser doesn’t have the permissions required to perform a command. To ensure that LabVIEW does have the necessary permissions, there are two options:

  1. The first option is to start the process from inside LabVIEW. If the process is created in LabVIEW, Linux will assign lvuser with all the necessary permissions to interact with, and kill, that process.
  2. If this is not possible, the kill command given via the System Exec VI should use a different syntax: “sudo kill -9 [process number]”. This will stop a process that the normal kill command cannot. An explanation of this syntax can be found in the Additional Information section below.

Additional Information

The syntax listed above will work even in circumstance where the default Linux kill command will not, because:

  • The term “sudo” increasing the permissions that the command has - similar to "Run as Administrator" on Windows.
  • The “-9” suffix, immediately stops the process, preventing any shutdown procedures from happening. Some programs include code to perform a predetermined shutdown procedure. The “-9” suffix stops the process without allowing that code to execute.

When using this, be careful to make sure the process ID is correct, as accidentally killing the wrong process can have adverse unintended consequences.