Skip to content
Snippets Groups Projects
Commit 9aaa2d3a authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Don't normalize the open mode for popen()

popen() does not accept all the normal modes... especially on
Linux which doesn't even allow the default "r+" mode.

Suck it penguin heads.
parent 68c44d27
Branches
No related tags found
No related merge requests found
Pipeline #2408 failed
if (system.platform == 'Win32')
exit();
let f = new File("/bin/ls");
if (!f.popen("r"))
throw new Error(`popen() failed! {f.error}`);
while(f.is_open) {
let l = f.readln();
if (!l)
f.close();
}
......@@ -386,7 +386,9 @@ js_popen(JSContext *cx, unsigned argc, JS::Value *arglist)
mode = "r+"; /* default mode */
if (!js_argc(cx, args, "su", &mode, &bufsize))
return false;
normalizemode(cx, mode.c_str(), fpt->mode, sizeof(fpt->mode), NULL, NULL);
// Don't normalize the mode... extra flags are not valid here.
//normalizemode(cx, mode.c_str(), fpt->mode, sizeof(fpt->mode), NULL, NULL);
SAFECOPY(fpt->mode, mode.c_str());
fpt->fp = popen(fpt->name, fpt->mode);
if (fpt->fp != NULL) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment