Beenden
  • Globale Community
    • Sprache:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티

Killing child process in CEP node.js

Beitragender ,
Jun 14, 2021 Jun 14, 2021

Dear ppro fellows,

I have a strange behavior of child process in node js,

1. First I start it (in my custom invisible panel) setting it as a global var:

const exec1 = require('child_process').exec;
var exec1_obj =  exec1(mypath_to_exe, function(err, stdout, stderr) {alert(err);});

Then I listen to a specific event:

csInterface.addEventListener("com.adobe.csxs.events.ExtensionUnloaded", function(evt){
alert(evt.data);
exec1_obj.kill();
alert("Closed app");
});

Now, after the event triggered I get alert with evt.data and I also get alert "Closed app". But my process (my exe file which generates my custom UI)  survives this!

However, if I kill the same process on the spot like this:

const exec1 = require('child_process').exec;
var exec1_obj =  exec1('"'+new_path+'"', function(err, stdout, stderr) {alert(err);});
exec1_obj.kill();

it does gets killed immediately.

How can this be?

What do I miss here?

Yaroslav.

 

 

THEMEN
SDK , Benutzeroberfläche oder Arbeitsbereiche
2.0K
Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines

correct answers 1 richtige Antwort

Beitragender , Jun 14, 2021 Jun 14, 2021

After extensive googling I figure out how to do it. For those treading this difficult path of Windows CEP panel developing.

The only reliable way to kill the process is to summon windows taskkill function.

So what you need to do is as folllows.

1. First, you create a child process:

const exec1 = require('child_process').exec;
var exec1_obj =  exec1(your_path, function(err, stdout, stderr) {alert(err);});

 and then you also spawn another process for the killing function

var spawn = require('child_proce
...
Übersetzen
Beitragender ,
Jun 14, 2021 Jun 14, 2021

After extensive googling I figure out how to do it. For those treading this difficult path of Windows CEP panel developing.

The only reliable way to kill the process is to summon windows taskkill function.

So what you need to do is as folllows.

1. First, you create a child process:

const exec1 = require('child_process').exec;
var exec1_obj =  exec1(your_path, function(err, stdout, stderr) {alert(err);});

 and then you also spawn another process for the killing function

var spawn = require('child_process').spawn;    

Then, to kill your exec1 process from some funtion (in my case it was event listener) you insert the following line inside your function:

spawn("taskkill", ["/pid", exec1_obj.pid, '/f', '/t']);

That did the job for me.

Yaroslav.

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Entdecker ,
Nov 10, 2022 Nov 10, 2022
AKTUELL

Hello, sorry to bother you, but can you help me. I'm trying to get the output of my child_process. Here is an example, but I can't get anything out, the stdout is blank.

 

var exec = require('child_process').exec;
var child = exec('C:\\Program Files\\Adobe\\Adobe Creative Cloud Experience\\libs\\node.exe', ['--version'], function(err, stdout, stderr) {alert(data);});

 

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines