Skip to content

Popen native or C import #458

Answered by arshajii
john9631 asked this question in Q&A
Aug 29, 2023 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Hi @john9631 -- popen should actually take two cobjs (which correspond to the char * arguments in C). Here is the modified code which also calls fgets:

from C import popen(cobj, cobj) -> cobj
from C import fgets(cobj, i32, cobj) -> cobj

pp = popen("ls -l".c_str(), "r".c_str())

n = 1000
p = cobj(n)
fgets(p, i32(n), pp)
print('read:', str.from_ptr(p))

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@john9631
Comment options

Answer selected by john9631
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants