For future reference, here is a way to use execvp() from node:

const ffi = require('ffi');
const ref = require('ref');
const ArrayType = require('ref-array');
const stringAry = ArrayType('string');
var current = ffi.Library(null,
                          { execvp: ['int', ['string',
                                             stringAry]],
                            dup2: ['int', ['int', 'int']]});
current.dup2(process.stdin._handle.fd, 0);
current.dup2(process.stdout._handle.fd, 1);
current.dup2(process.stderr._handle.fd, 2);
var ret = current.execvp("/usr/bin/program", ['progname', 'arg1, 'arg2',
                                          arg3, ref.NULL]);


On Tue, Jan 17, 2017 at 11:55 AM, Matt <[email protected]> wrote:
> cp.spawn/spawnSync have very different semantics to execve though. They
> maintain a parent process, which I imagine is what Daniel is trying to
> avoid.
>
> On Mon, Jan 16, 2017 at 2:26 PM, Fedor Indutny <[email protected]> wrote:
>>
>> I'm not sure if it helps, but have you already tried
>> child_process.spawnSync?
>>
>> On Mon, Jan 16, 2017 at 09:11 Daniel Risacher <[email protected]> wrote:
>>>
>>> I find deep irony in your answer, in that I was trying to rewrite a
>>> simple script that I'd already written in perl with a nodejs version to
>>> eliminate the perl dependency.
>>>
>>>
>>> On Thursday, January 12, 2017 at 9:53:38 AM UTC-5, Matt Sergeant wrote:
>>>>
>>>> No there's no equivalent to it, mostly because Windows has no way to do
>>>> it. Maybe try perl instead.
>>>>
>>>> On Fri, Jan 6, 2017 at 5:08 PM, Daniel Risacher <[email protected]>
>>>> wrote:
>>>>>
>>>>> Is it possible to execute another program in the manner of execve(2)?
>>>>>
>>>>> I.e. as the man page says, "execve() does not return on success, and
>>>>> the text, data, bss, and stack of the calling process are overwritten by
>>>>> that of the program loaded."
>>>>>
>>>>> I don't see any function in the core modules that does this.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>>
>>>>>
>>>>> Job board: http://jobs.nodejs.org/
>>>>>
>>>>>
>>>>> New group rules:
>>>>> https://gist.github.com/othiym23/9886289#file-moderation-policy-md
>>>>>
>>>>>
>>>>> Old group rules:
>>>>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>>>>>
>>>>>
>>>>> ---
>>>>>
>>>>>
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "nodejs" group.
>>>>>
>>>>>
>>>>>
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to [email protected].
>>>>>
>>>>>
>>>>> To post to this group, send email to [email protected].
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/nodejs/026d265f-93a4-4369-ae5e-7ef6433e0d3e%40googlegroups.com.
>>>>>
>>>>>
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> --
>>>
>>>
>>> Job board: http://jobs.nodejs.org/
>>>
>>>
>>> New group rules:
>>> https://gist.github.com/othiym23/9886289#file-moderation-policy-md
>>>
>>>
>>> Old group rules:
>>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>>>
>>>
>>> ---
>>>
>>>
>>> You received this message because you are subscribed to the Google Groups
>>> "nodejs" group.
>>>
>>>
>>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to [email protected].
>>>
>>>
>>> To post to this group, send email to [email protected].
>>>
>>>
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/nodejs/0e858cf2-d3de-44d9-aa2e-18805cd764d4%40googlegroups.com.
>>>
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>>
>> --
>> Job board: http://jobs.nodejs.org/
>> New group rules:
>> https://gist.github.com/othiym23/9886289#file-moderation-policy-md
>> Old group rules:
>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "nodejs" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/nodejs/CAEv2VfKFHS803Lh9srVB%3DqSy-wFi20j6%2B%2BDEfo%2BQcg74aStb3A%40mail.gmail.com.
>>
>> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> Job board: http://jobs.nodejs.org/
> New group rules:
> https://gist.github.com/othiym23/9886289#file-moderation-policy-md
> Old group rules:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "nodejs" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/nodejs/4vtWG1KCQC4/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/nodejs/CAPJ5V2Z54nrCzGSUFAs2TvLPSHNivG-6WUH5UkXjGZWk1PfOLA%40mail.gmail.com.
>
> For more options, visit https://groups.google.com/d/optout.

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/CAAD1OeJ97Z-b5nDKTPyAGvOaZrNa%2B%3Dw_z0XJ-aNhr545xiKzuA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to