Changed execute delay method

This commit is contained in:
Michiel Broek 2004-03-15 18:48:23 +00:00
parent e2c1df6639
commit 0d2fc1c841
3 changed files with 30 additions and 20 deletions

View File

@ -1,10 +1,5 @@
$Id$
If you feel lucky then try this version, if not just wait
a few days so that I fix the destructive bugs that might
be present in this version.
One found, destroyed 5 fileareas, don't think it won't happen!
v0.51.2 06-Mar-2004
@ -26,6 +21,11 @@ v0.51.2 06-Mar-2004
Removed all references to costsharing for ticfiles which wasn't
fully implemented.
libcommon.a:
Moved the initial delay in the execute functions to the child
process, that may be the trick to work around the lost child
messages.
mbcico:
Updated file request function to new files database structure.
Fixed a compile problem on FreeBSD 5.1

4
TODO
View File

@ -1,6 +1,6 @@
$Id$
MBSE BBS V0.51.1 TODO list.
MBSE BBS V0.51.2 TODO list.
---------------------------
These are a list of things that must be implemented one way or
@ -127,8 +127,6 @@ mbfido:
just handle the record as a dupe (In test again).
mbcico:
N: Further investigate binkp tty_error hangup (Seems Oke).
L: Implement binkp option ND.
N: Implement PLZ turn off m_get command.

View File

@ -36,8 +36,8 @@ int e_pid = 0; /* Execute child pid */
int _execute(char **, char *, char *, char *);
int _execute(char **args, char *in, char *out, char *err)
int _execute(char **, char *, char *, char *, int);
int _execute(char **args, char *in, char *out, char *err, int priority)
{
char buf[PATH_MAX];
int i, pid, terrno = 0, status = 0, rc = 0;
@ -55,6 +55,12 @@ int _execute(char **args, char *in, char *out, char *err)
fflush(stderr);
if ((pid = fork()) == 0) {
/*
* A delay in the child to prevent it returns before the main
* process sess it ever started.
*/
msleep(150);
if (in) {
close(0);
if (open(in,O_RDONLY) != 0) {
@ -78,15 +84,16 @@ int _execute(char **args, char *in, char *out, char *err)
}
errno = 0;
if (priority) {
rc = getpriority(PRIO_PROCESS, 0);
if (errno == 0) {
rc = setpriority(PRIO_PROCESS, 0, 15);
rc = setpriority(PRIO_PROCESS, 0, priority);
if (rc)
WriteError("$execv can't set priority to 15");
WriteError("$execv can't set priority to %d", priority);
}
}
rc = execv(args[0],args);
WriteError("$execv \"%s\" returned %d", MBSE_SS(args[0]), rc);
setpriority(PRIO_PROCESS, 0, 0);
exit(MBERR_EXEC_FAILED);
}
@ -98,6 +105,7 @@ int _execute(char **args, char *in, char *out, char *err)
} while (((rc > 0) && (rc != pid)) || ((rc == -1) && (errno == EINTR)));
terrno = errno;
if (priority)
setpriority(PRIO_PROCESS, 0, 0);
errno = terrno;
@ -144,8 +152,7 @@ int execute(char **args, char *in, char *out, char *err)
#ifdef __linux__
sync();
#endif
msleep(300);
rc = _execute(args, in, out, err);
rc = _execute(args, in, out, err, 15);
#ifdef __linux__
sync();
#endif
@ -237,6 +244,12 @@ int _execsh(char *cmd, char *in, char *out, char *err)
fflush(stderr);
if ((pid = fork()) == 0) {
/*
* A delay in the child to prevent it returns before the main
* process sess it ever started.
*/
msleep(300);
if (in) {
close(0);
if (open(in, O_RDONLY) != 0) {
@ -291,7 +304,6 @@ int execsh(char *cmd, char *in, char *out, char *err)
#ifdef __linux__
sync();
#endif
msleep(300);
rc = _execsh(cmd, in, out, err);
#ifdef __linux__
sync();