パイプとフォークを使用して、次のようなコマンドを実行しています
猫ファイル.tar.gz | myprogram -c "tar -zvt" -i "remoteMachineIp"
しかし、私がそうするなら
myprogram -c "bash" -i "remoteMachineIp"
bash は問題ありませんが、tty はありません。tty がないと、vim コマンドを呼び出すと、vi がめちゃくちゃに開きます。
tty を使用して execlp で bash を呼び出す方法を教えてください。
コード例
if(cm->pid2==0){ //pipe and fork to send data to my execlp
close(cm->fout[0]);
dup2(cm->fout[1], 1);
execlp("bash", "bash", "-c", command.c_str(), NULL); // command is mycommand so is bash -c "bash"
}
else{
close(cm->fout[1]);
while((size=read(cm->fout[0], buffer, 2000)) > 0){
cm->message->send(buffer, size); //send the data to my program
}
//Close it and send the return code
問題は、execlp が bash を返すことですが、tty は返されません。
ttyでbashを呼び出すにはどうすればよいですか?
ありがとう