I write a shell who must run under NetBSD, but I'm a fan of
Linux, so I'd like that it could run also under Linux.
So here is my problem :
actually i do the job control, i write few lines are efficient under
netbsd
but who doesn't work under linux.
so here is my piece of my code with annotation :
/*
** exec_cmd.c for in
**
** Made by nicolas delon
**
** Started on Fri Jan 21 12:31:06 2000 nicolas delon
## Last update Fri Apr 28 09:26:48 2000 nicolas delon
*/
#include "my/my.h"
#include "shell.h"
#include <fcntl.h>
#include <signal.h>
void exec_cmd(char *cmd[], int bg)
{
int pid;
signal(SIGCHLD, waiting);
if ((pid = fork()) == -1)
{
perror("mysh");
return;
}
else if (pid)
{
if (bg)
return;
else
{
setpgid(pid, pid);
tcsetpgrp(open("/dev/tty", O_RDONLY), pid)
pause();
tcsetpgrp(open("/dev/tty", O_RDONLY), getpid()) /* here
is the mistake, the child die, the father continue
and
he reveices a SIGTTOU
under
Linux (it works under NetBSD), and it stops*/
}
}
else
{
usleep(1);
setpgid(getpid(), getpid());
if (!bg)
{
tcsetpgrp(open("/dev/tty", O_RDONLY), getpid())
}
cmd = redirections(cmd);
if (execvp(cmd[0], cmd) == -1)
{
aff_error("mysh: ");
aff_error(cmd[0]);
aff_error(": ");
aff_error("command not found\n");
exit(0);
}
}
so if anybody have a solution for this problem....Quote:}