add the ability to start apps (still buggy)

This commit is contained in:
Marian Ohligs 2011-05-24 17:23:10 +02:00
parent cf570ee42a
commit f54b06a807
3 changed files with 21 additions and 11 deletions

View file

@ -27,10 +27,6 @@ extern int errno;
int main(int argc, char** argv)
{
int i;
char* str = (char *)malloc(40000 * sizeof(char));
scanf("%s", str);
printf("SCANF: %s", str);
fflush(NULL);
printf("test!");
return errno;
}

Binary file not shown.

View file

@ -1,6 +1,10 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/wait.h>
void showlogo() {
printf("\n\n");
@ -19,7 +23,8 @@ void help() {
int main(int argc, char** argv)
{
char* command = malloc(1024*sizeof(char));
int size;
int size, status = 0;
pid_t pid;
system("clear");
showlogo();
while(1) {
@ -29,11 +34,20 @@ int main(int argc, char** argv)
}
if(!strcmp(command, "help")) {
help();
}
else {
char* argv[] = {command, NULL};
execve(command, argv, NULL);
} else {
//pid = fork();
//if (pid == 0) { //child
char* newargv[] = {command, NULL};
char* newenv[] = {"USER=root", "PATH=/bin:/sbin:/usr/bin", "PWD=/", "TEMP=/tmp", NULL};
execve(command, newargv, newenv);
return errno;
//} else {
// wait(&status);
// printf("Beendet");
//}
}
}
return errno;
}