You are not logged in.

#1 2015-03-23 10:14:02

nierro
Member
From: Milan, Italy
Registered: 2011-09-02
Posts: 849

C and ncurses: execl in a specific window

Hi!
Is there a way to call vfork() and then execl a system program (/usr/bin/nano for example) in a specific ncurses window and not stdscr? I'd like to achieve that, having 2 subwin of stdscr, nano will be launched in the first, but the second window will stay untouched. So you can open 2 files in the same time in 2 different windows.
Is there a way? I tried googling but couldn't find anything.

Thanks everyone!

Offline

#2 2015-03-23 11:55:02

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,330
Website

Re: C and ncurses: execl in a specific window

There is a way to do this, but I don't know that it can be done with just the tools you describe.  You need a pseudo terminal set up in the ncurses window.  The ncurses window only provides a space on which to draw, it doesn't provide a new terminal - but a pty can do this.  You might want to check out the code of screen/tmux/dvtm (the last might have the simplest code as the first two have lots of other features).

EDIT: vt_forkpty on line 1564 of vt.c in the dvtm-git code would probably be the key.

Last edited by Trilby (2015-03-23 11:59:27)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2015-03-23 12:22:12

nierro
Member
From: Milan, Italy
Registered: 2011-09-02
Posts: 849

Re: C and ncurses: execl in a specific window

Mmmh thanks to you i might have found that http://www.gnu.org/software/libc/manual … Pairs.html (forkpty) should be what i'm looking for.
I'll try and report back here, possibly with a little code snippet for future people.
Again, thanks for your hint!

Last edited by nierro (2015-03-23 12:22:28)

Offline

Board footer

Powered by FluxBB