consoled now supports a program to be run instead of the shell being supplied
via command line parameters. Not tested yet. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13677 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -7,15 +7,16 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <OS.h>
|
|
||||||
#include <image.h>
|
#include <image.h>
|
||||||
|
#include <OS.h>
|
||||||
|
|
||||||
#include <termios.h>
|
#include <ctype.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <termios.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
|
||||||
//#define USE_INPUT_SERVER
|
//#define USE_INPUT_SERVER
|
||||||
@@ -291,7 +292,7 @@ start_process(int argc, const char **argv, struct console *con)
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main(void)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
@@ -309,18 +310,38 @@ main(void)
|
|||||||
dup2(gConsole.tty_slave_fd, 1);
|
dup2(gConsole.tty_slave_fd, 1);
|
||||||
dup2(gConsole.tty_slave_fd, 2);
|
dup2(gConsole.tty_slave_fd, 2);
|
||||||
|
|
||||||
for (;;) {
|
if (argc > 1) {
|
||||||
pid_t shell_process;
|
// a command was given: we run it only once
|
||||||
|
|
||||||
|
// get the command argument vector
|
||||||
|
int commandArgc = argc - 1;
|
||||||
|
const char **commandArgv = new const char*[commandArgc + 1];
|
||||||
|
for (int i = 0; i < commandArgc; i++)
|
||||||
|
commandArgv[i] = argv[i + 1];
|
||||||
|
|
||||||
|
commandArgv[commandArgc] = NULL;
|
||||||
|
|
||||||
|
// start the process
|
||||||
|
pid_t process;
|
||||||
status_t returnCode;
|
status_t returnCode;
|
||||||
const char *argv[3];
|
|
||||||
|
|
||||||
argv[0] = "/bin/sh";
|
process = start_process(commandArgc, commandArgv, &gConsole);
|
||||||
argv[1] = "--login";
|
|
||||||
shell_process = start_process(2, argv, &gConsole);
|
|
||||||
|
|
||||||
wait_for_thread(shell_process, &returnCode);
|
wait_for_thread(process, &returnCode);
|
||||||
|
|
||||||
puts("Restart shell");
|
} else {
|
||||||
|
// no command given: start a shell in an endless loop
|
||||||
|
for (;;) {
|
||||||
|
pid_t shellProcess;
|
||||||
|
status_t returnCode;
|
||||||
|
const char *shellArgv[] = { "/bin/sh", "--login", NULL };
|
||||||
|
|
||||||
|
shellProcess = start_process(2, shellArgv, &gConsole);
|
||||||
|
|
||||||
|
wait_for_thread(shellProcess, &returnCode);
|
||||||
|
|
||||||
|
puts("Restart shell");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
acquire_sem(gConsole.wait_sem);
|
acquire_sem(gConsole.wait_sem);
|
||||||
|
|||||||
Reference in New Issue
Block a user