Send input str direct to tty

Submitted by lepton on Fri, 07/10/2020 - 13:16

//simulate terminal input

#include <sys/ioctl.h>
#include <termios.h>
#include <stdio.h>
#include <stdlib.h>

 

void stackchar(char c) {
    if (ioctl(0, TIOCSTI, &c) < 0) {
        perror("ioctl");
        exit(1);
    }
}
int main(int argc, char *argv[]) {
    char *str=argv[1];
    int len=(int)strlen(str);
    for (int i=0; i<len; i++) {
        stackchar(str[i]);
    }
    stackchar('\n');
    return 0;;
}

Comments

GreFouse (not verified)

Thu, 05/19/2022 - 20:36

"Star of the South"Best stage got on job Alex Ferguson. Team managed to win different prestigious awards. While about the past glory has only remembering. However Red Devils still be able to show excellent football.Composition first time appeared in early last century. During years existence "Star of the South" won title most famous team FRG. Total about 60 significant achievements.Help club huge. Manchester United appeared late 1870s. During the existence managed overcome through different problems. bets10 yasad?s? m? Annual income decent. Squad earns on resale of players, advertising, sponsorship. Significant income became sale seats in the stands during games.2. The procedure for selecting players for the team.Detailed work helps creamy win championships. About the merits of the composition you can talk for long. More 10 times Real Madrid won in European cup competitions.Leading positions in Spanish football club tried to take over at the dawn of existence. Achieve this succeeded thanks to set reasons. The team is famous for its comprehensive approach to training. Mentors try to focus on different parameters:

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.