I am working on an embedded project, where I need a program without external dependencies that works like screen or tmux. These two programs are not good because they need other libraries.
Since I only need to detach a program, being able to log-out and getting it back when I log-in again, I was wondering whether I can write a small program for that.
Do you know which calls (in C) I need to do to detach the program and to have it back?
If i understand your requirements correctly, you could theoretically use termios struct and ioctl to achieve this.
ioctl(0, TIOCNOTTY, NULL);
to detach and
ioctl(0, TIOCSCTTY, 1);
to attach back to the terminal. However, it doesn't actually perform the job.
The following solution describes a not so nice but practical work around
tty demulsified
The primary intention there is to attach program to another terminal but i believe that is the way you can achieve your goal too.
Regarding your mention of embedded platform, you might be able to find some help from busybox
It compiles for embedded linux with a pretty small binary and contains most of commonly used linux utilities such as getty, stty etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With