I have a python module that work with webcam by opencv in ubuntu. I should execute it from nodejs so I use shelljs package and run shell.exec('sudo pkill -P ${pythonProcess.pid}')
. It does not close webcam otherwise it working in terminal of ubuntu. I type sudo pkill -P <PID>
in terminal and process is terminated and close webcam immediately. anybody has any idea why? tnx.
Asked
Active
Viewed 180 times
0

r.a.shehni
- 350
- 1
- 4
- 11
-
I'm not familiar with nodejs, and as such shelljs, but what happens if you run sudo shell.exec(...)? Or is that not even possible? If shell.exec is a command within the script then maybe the script needs su permission first? – pudup Apr 25 '21 at 11:47
-
sorry for my bad explain. shell.exec is a instruction of shelljs package of nodejs. and I run it in nodejs. It runs system script in a shell of OS. pkill command in ubuntu needs su permission so I pass script string to shelljs.exec with sudo. Should I take su permission to shelljs package or nodejs? – r.a.shehni Apr 28 '21 at 10:02
-
Do you have to enter a password to run `sudo pkill -P
`? – Thomas Sablik Apr 28 '21 at 10:05 -
Where is `pythonProcess.pid` defined and does it contain the correct PID? – tripleee Apr 28 '21 at 10:19
-
@r.a.shehni Try su permission with both? I'll step back from helping you on this since I'm unfamiliar with nodejs. Good luck. – pudup Apr 28 '21 at 10:41
-
no I have not. I setting up it on NOPASS.@ThomasSablik – r.a.shehni Apr 28 '21 at 15:59
-
pythonProcess is created by another shelljs.exec(...) instruction and yes its PID is correct because when I type sudo pkill -P by pythonProcess.pid, this command is terminated process and close webcam window .@tripleee – r.a.shehni Apr 28 '21 at 16:06