2010-11-22 07:21:32 -08:00
|
|
|
#include "e.h"
|
2011-08-31 14:56:26 -07:00
|
|
|
#include <sys/wait.h>
|
2006-01-09 20:23:43 -08:00
|
|
|
|
2011-08-07 07:03:21 -07:00
|
|
|
/* public variables */
|
|
|
|
EAPI unsigned long e_alert_composite_win = 0;
|
|
|
|
|
2011-08-31 06:52:29 -07:00
|
|
|
EINTERN int
|
|
|
|
e_alert_init(void)
|
2005-06-14 22:06:45 -07:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2011-08-31 06:52:29 -07:00
|
|
|
EINTERN int
|
|
|
|
e_alert_shutdown(void)
|
2005-06-14 22:06:45 -07:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2012-06-20 23:19:43 -07:00
|
|
|
EAPI void
|
|
|
|
e_alert_show(int sig)
|
2005-06-14 22:06:45 -07:00
|
|
|
{
|
2011-08-31 06:52:29 -07:00
|
|
|
char *args[4];
|
|
|
|
pid_t pid;
|
2005-06-14 22:06:45 -07:00
|
|
|
|
2011-08-31 06:52:29 -07:00
|
|
|
#define E_ALERT_EXE "/enlightenment/utils/enlightenment_alert"
|
2005-06-14 22:06:45 -07:00
|
|
|
|
2011-08-31 06:52:29 -07:00
|
|
|
args[0] = alloca(strlen(e_prefix_lib_get()) + strlen(E_ALERT_EXE) + 1);
|
|
|
|
strcpy(args[0], e_prefix_lib_get());
|
|
|
|
strcat(args[0], E_ALERT_EXE);
|
2005-06-14 22:06:45 -07:00
|
|
|
|
2011-08-31 06:52:29 -07:00
|
|
|
args[1] = alloca(10);
|
|
|
|
snprintf(args[1], 10, "%d", sig);
|
2006-07-05 12:38:59 -07:00
|
|
|
|
2011-08-31 06:52:29 -07:00
|
|
|
args[2] = alloca(21);
|
|
|
|
snprintf(args[2], 21, "%lu", (long unsigned int)getpid());
|
|
|
|
|
|
|
|
args[3] = alloca(21);
|
|
|
|
snprintf(args[3], 21, "%lu", e_alert_composite_win);
|
|
|
|
|
|
|
|
pid = fork();
|
|
|
|
if (pid < -1)
|
|
|
|
goto restart_e;
|
|
|
|
|
|
|
|
if (pid == 0)
|
|
|
|
{
|
|
|
|
/* The child process */
|
|
|
|
execvp(args[0], args);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* The parent process */
|
|
|
|
pid_t ret;
|
|
|
|
int status = 0;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
ret = waitpid(pid, &status, 0);
|
|
|
|
if (errno == ECHILD)
|
|
|
|
break ;
|
|
|
|
}
|
|
|
|
while (ret != pid);
|
2005-06-14 22:06:45 -07:00
|
|
|
|
2011-08-31 06:52:29 -07:00
|
|
|
if (status == 0)
|
|
|
|
goto restart_e;
|
2005-06-14 22:06:45 -07:00
|
|
|
|
2011-08-31 06:52:29 -07:00
|
|
|
if (!WIFEXITED(status))
|
|
|
|
goto restart_e;
|
|
|
|
|
|
|
|
if (WEXITSTATUS(status) == 1)
|
|
|
|
goto restart_e;
|
|
|
|
|
|
|
|
exit(-11);
|
|
|
|
}
|
|
|
|
|
|
|
|
restart_e:
|
2011-11-17 02:19:50 -08:00
|
|
|
if (getenv("E_START_MTRACK"))
|
|
|
|
e_util_env_set("MTRACK", "track");
|
2011-08-31 06:52:29 -07:00
|
|
|
ecore_app_restart();
|
2005-06-14 22:06:45 -07:00
|
|
|
}
|