Code Monkey home page Code Monkey logo

child_process's People

Contributors

alanhamlett avatar anyab5 avatar chpio avatar dependabot[bot] avatar huw avatar mathieudutour avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

child_process's Issues

Subprocess pid is always 0

The pid property is always 0 in my testing.

var subprocess = spawn('mycmd')
subprocess.pid // => 0

It looks like calling processIdentifier() before launch() will give you a 0:

var task = NSTask.alloc().init()
task.processIdentifier() // => 0

result.pid is being set to String(task.processIdentifier()) but this happens before launch() is called because that is done via setImmediate() here:

setImmediate(() => task.launch())

Unknown encoding in async process

import { exec } from '@skpm/child_process';

export default function test() {
  exec('echo test', (err, stdout, stderr) => {
    console.log('err', err);
    console.log('stdout', stdout);
    console.log('stderr', stderr);
  });
}
Error: Unknown encoding: NSData

child.stdout.setEncoding('NSData')

fork?

The readme says all child_process methods are supported, but I don't see fork

Some async commands hang indefinitely

I noticed this while playing around, and I can't quite figure out the cause. When running certain commands asynchronously, the module fails to release the fiber it opens, which causes a large memory leak. Further, the commands never return any values. For example:

exec('/bin/ps', null, (error, stdout, stderr) => {
  log(`DEBUG: ${stdout}`);
  log(`DEBUG: ${stderr}`);
});

Will hang and cause Sketch to eat memory, as well as fill up the Console really quickly:

The output I would expect is:

❯ ps
  PID TTY           TIME CMD
16534 ttys001    0:02.87 /usr/local/bin/zsh -l
10772 ttys003    0:02.60 /usr/local/bin/zsh -l
30746 ttys003    0:00.29 node /usr/local/Cellar/yarn/1.13.0/libexec/bin/yarn.js watch
30088 ttys005    0:00.74 /usr/local/bin/zsh --login

Writing to sdtin crashes sketch

Hi,

i need to run code in nodejs. So my idea was to spawn a nodejs process and communicate with it by sending jsonl messages to stdin (you call it sdtin) & getting jsonl messages back from stdout.

But when i attempt to write to stdin it just crashes sketch. No crash reports in console.

const child = spawn(
	path.resolve(process.cwd(), "./Contents/Sketch/external"),
	[],
	{cwd: path.resolve(process.cwd(), "./Contents/Sketch")},
);

// @ts-ignore
const stdin: Writable = child.stdin || child.sdtin;

const buf = Buffer.from(JSON.stringify({type: "getImages"}) + "\n");
console.log("buf", buf);

await new Promise<void>((onOk, onErr) => {
	// crashes here
	stdin.write(buf, (err) => {
		if (err !== null && err !== undefined) {
			onErr(err);
		} else {
			onOk();
		}
	});
});

exec function stdout length

I called exec in my Sketch Plugin, but the return value cannot be returned completely, it can only return 4060 characters. Can you help me?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.