1999-11-18 20:05:24 -08:00
|
|
|
/*
|
2002-02-03 12:53:07 -08:00
|
|
|
* Copyright (C) 1997-2002, Michael Jennings
|
1999-11-18 20:05:24 -08:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to
|
|
|
|
* deal in the Software without restriction, including without limitation the
|
|
|
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
* sell copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies of the Software, its documentation and marketing & publicity
|
|
|
|
* materials, and acknowledgment shall be given in the documentation, materials
|
|
|
|
* and software packages that this Software was used.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
|
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
1999-08-17 16:01:18 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
static const char cvs_ident[] = "$Id$";
|
|
|
|
|
|
|
|
#include "../config.h"
|
|
|
|
#include "feature.h"
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <stdlib.h>
|
1999-08-17 18:12:47 -07:00
|
|
|
#include <string.h>
|
1999-08-17 16:01:18 -07:00
|
|
|
#include <signal.h>
|
|
|
|
#ifdef HAVE_SYS_WAIT_H
|
|
|
|
# include <sys/wait.h>
|
|
|
|
#endif
|
|
|
|
|
1999-08-17 18:12:47 -07:00
|
|
|
#include "command.h"
|
|
|
|
#include "misc.h"
|
|
|
|
#include "system.h"
|
1999-08-17 16:01:18 -07:00
|
|
|
|
2000-08-30 22:41:44 -07:00
|
|
|
/*static eterm_sighandler_t old_handler = (eterm_sighandler_t) NULL;*/
|
Wed Apr 12 21:18:19 PDT 2000 Michael Jennings <mej@eterm.org>
This is the initial commit with Imlib2 support. READ THIS CAREFULLY.
There is important information in this commit message that will keep
you from getting screwed.
First off, support for Imlib 1.x is GONE. It is no longer supported
as of now. If you want to continue using it, do NOT install this
version. I tried to support both for awhile, but the code ended up
being way too ugly and hackish. Imlib2 is the future. And trust me,
when you see what we do with this future, you'll be happy for the
switch.
The good news is that most of the basics work. Transparency still
works, and the basic image stuff works. Most users won't notice any
major problems, so long as your Imlib2 is 100% up-to-date.
However, a few things still don't work:
1. Auto mode is a bit broken. You'll get X errors in XFree86 4.0.
Don't use it if you're running XFree 4.
2. Color modifiers for images don't work. At all.
3. Transparency shading/tinting will not work in 8bpp or lower. Life
blows sometimes. Sorry. Time for a real video card. :-)
4. The built-in icon is broken.
5. You WILL need to update your theme.cfg files. The borders on the
horizontal and vertical bar images were incorrect when combined with
the new anti-aliased scaling. The horizontal bars should have a right
border of 3. Vertical bars should have a bottom border of 3. The
menu images should have both right *and* bottom borders of 3. You can
either make those changes by hand, or use the --with-theme-update
option to autogen.sh. Your call.
I think that covers everything I've run into. I will point out that
I don't really take advantage of a lot of the Imlib2 features just
yet. My first priority is to make all the stuff that worked before
work again (or at least the important stuff). Then I'll work on
new features.
So there it is. If you're not ready for it, don't use it. But if you
are, I hope you like it.
SVN revision: 2478
2000-04-12 21:19:05 -07:00
|
|
|
|
1999-08-17 16:01:18 -07:00
|
|
|
int
|
|
|
|
wait_for_chld(int system_pid)
|
|
|
|
{
|
2002-05-04 07:25:30 -07:00
|
|
|
int pid, status = 0, save_errno = errno, code;
|
|
|
|
|
|
|
|
D_OPTIONS(("wait_for_chld(%ld) called.\n", system_pid));
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
do {
|
|
|
|
errno = 0;
|
|
|
|
} while ((((pid = waitpid(system_pid, &status, WNOHANG)) == -1) && (errno == EINTR)) || !pid);
|
|
|
|
/* If the child that exited is the command we spawned, or if the
|
|
|
|
child exited before fork() returned in the parent, it must be
|
|
|
|
our immediate child that exited. We exit gracefully. */
|
|
|
|
if ((pid == -1) && (errno == ECHILD)) { /* No children exist. Punt. */
|
|
|
|
errno = save_errno;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
D_OPTIONS(("%ld exited.\n", pid));
|
|
|
|
if (pid == system_pid || system_pid == -1) {
|
|
|
|
if (WIFEXITED(status)) {
|
|
|
|
code = WEXITSTATUS(status);
|
|
|
|
D_OPTIONS(("Child process exited with return code %lu\n", code));
|
|
|
|
} else if (WIFSIGNALED(status)) {
|
|
|
|
code = WTERMSIG(status);
|
|
|
|
D_OPTIONS(("Child process was terminated by unhandled signal %lu\n", code));
|
|
|
|
} else {
|
|
|
|
code = 0;
|
|
|
|
}
|
|
|
|
return (code);
|
|
|
|
}
|
|
|
|
errno = save_errno;
|
2000-02-15 19:37:34 -08:00
|
|
|
}
|
2002-05-04 07:25:30 -07:00
|
|
|
return 0;
|
1999-08-17 16:01:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Replace the system() call with a fork-and-exec that unprivs the child process */
|
|
|
|
|
|
|
|
int
|
|
|
|
system_wait(char *command)
|
|
|
|
{
|
|
|
|
|
2002-05-04 07:25:30 -07:00
|
|
|
pid_t pid;
|
|
|
|
|
|
|
|
D_OPTIONS(("system_wait(%s) called.\n", command));
|
|
|
|
|
|
|
|
if (!(pid = fork())) {
|
|
|
|
setreuid(my_ruid, my_ruid);
|
|
|
|
setregid(my_rgid, my_rgid);
|
|
|
|
execl("/bin/sh", "sh", "-c", command, (char *) NULL);
|
|
|
|
print_error("execl(%s) failed -- %s\n", command, strerror(errno));
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
} else {
|
|
|
|
D_OPTIONS(("%d: fork() returned %d\n", getpid(), pid));
|
|
|
|
return (wait_for_chld(pid));
|
|
|
|
}
|
|
|
|
ASSERT_NOTREACHED_RVAL(0);
|
1999-08-17 16:01:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
system_no_wait(char *command)
|
|
|
|
{
|
|
|
|
|
2002-05-04 07:25:30 -07:00
|
|
|
pid_t pid;
|
1999-08-17 16:01:18 -07:00
|
|
|
|
2002-05-04 07:25:30 -07:00
|
|
|
D_OPTIONS(("system_no_wait(%s) called.\n", command));
|
1999-08-17 16:01:18 -07:00
|
|
|
|
2002-05-04 07:25:30 -07:00
|
|
|
if (!(pid = fork())) {
|
|
|
|
setreuid(my_ruid, my_ruid);
|
|
|
|
setregid(my_rgid, my_rgid);
|
|
|
|
execl("/bin/sh", "sh", "-c", command, (char *) NULL);
|
|
|
|
print_error("execl(%s) failed -- %s\n", command, strerror(errno));
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
return (0);
|
1999-08-17 16:01:18 -07:00
|
|
|
}
|