Cordell
Mitglied
Hi,
ich habe folgenden Code:
Nach dem Kompilieren bekomme ich folgende Meldung:
------------------
in function main:
fork.c: (.text+0x104): undefined reference to 'eval_wait_stat'
collect2: ld returned 1 exit status
------------------
Kann jemand helfen?
Gruß,
Cordell
ich habe folgenden Code:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <errno.h>
#define CHILDREN 3 /* max. Anzahl Soehne */
int eval_wait_stat (int stat):
int main (void)
{
pid_t parent_pid, child_pid, /* Prozessnummern */
fork_pid, wait_pid,
parent_grp, child_grp; /* Prozessgruppen */
int child_stat, /* Zustand des Sohnes */
exit_val, /* "exit"-Wert des Sohnes */
i,j, /* Zählvariablen */
anz_children = 0; /* Anzahl Soehne */
exit_val = 10; /* zum Testen beliebiger Wert */
parent_pid = getpid ();
parent_grp = getpgrp ();
while (anz_children < CHILDREN)
{
fork_pid = fork ();
switch(fork_pid)
{
case -1: /* Fehler: kein Prozess erzeugt */
perror ("fork failed");
errno = 0;
break;
case 0: /* Sohnprozesse */
child_pid = getpid ();
child_grp = getpgrp ();
printf ("Sohnprozess. Prozess-Id: %ld Gruppen-Id: %ld "
"Vaterprozess-Id: %ld ", (long) child_pid,
(long) child_grp, (long) getppid ());
anz_children++;
exit (exit_val);
break;
default:
while (anz_children > 0)
{
wait_pid = wait (&child_stat);
if (wait_pid == -1)
{
perror ("wait");
errno = 0;
}
else
{
printf ("Vaterprozess. Sohnprozess %ld endet.\n",
(long) wait_pid);
eval_wait_stat (child_stat);
anz_children--;
}
}
}
}
return 0;
int eval_wait_stat (int stat)
{
if (WIFEXITED (stat) != 0)
{
printf ("\t\tSohnprozess endet mit Status %d.\n",
WEXITSTATUS (stat));
return 0;
}
if (WIFSIGNALED (stat) != 0)
{
printf ("\t\tSohnprozess wurde durch Signal %d beendet.\n",
WTERMSIG (stat));
return 0;
}
if (WIFSTOPPED (stat) != 0)
{
printf ("\t\tSohnprozess wurde durch Signal %d gestoppt.\n",
WSTOPSIG (stat));
}
#if (defined(SunOS) || defined(IRIX)) && !defined(_POSIX_C_SOURCE)
if (WIFCONTINUED (stat) != 0)
{
printf ("\t\tSohnprozess wurde fortgesetzt\n.");
}
#endif
return 1;
}
}
Nach dem Kompilieren bekomme ich folgende Meldung:
------------------
in function main:
fork.c: (.text+0x104): undefined reference to 'eval_wait_stat'
collect2: ld returned 1 exit status
------------------
Kann jemand helfen?
Gruß,
Cordell