update for beta release
[framework/uifw/e17.git] / src / bin / e_alert.c
1 #include "e.h"
2 #include <sys/wait.h>
3
4 /* public variables */
5 EAPI unsigned long e_alert_composite_win = 0;
6
7 EINTERN int
8 e_alert_init(void)
9 {
10    return 1;
11 }
12
13 EINTERN int
14 e_alert_shutdown(void)
15 {
16    return 1;
17 }
18
19 EAPI void 
20 e_alert_show(int sig) 
21 {
22    char *args[4];
23    pid_t pid;
24
25 #define E_ALERT_EXE "/enlightenment/utils/enlightenment_alert"
26
27    args[0] = alloca(strlen(e_prefix_lib_get()) + strlen(E_ALERT_EXE) + 1);
28    strcpy(args[0], e_prefix_lib_get());
29    strcat(args[0], E_ALERT_EXE);
30
31    args[1] = alloca(10);
32    snprintf(args[1], 10, "%d", sig);
33
34    args[2] = alloca(21);
35    snprintf(args[2], 21, "%lu", (long unsigned int)getpid());
36
37    args[3] = alloca(21);
38    snprintf(args[3], 21, "%lu", e_alert_composite_win);
39
40    pid = fork();
41    if (pid < -1)
42      goto restart_e;
43
44    if (pid == 0)
45      {
46         /* The child process */
47         execvp(args[0], args);
48      }
49    else
50      {
51         /* The parent process */
52         pid_t ret;
53         int status = 0;
54
55         do
56           {
57              ret = waitpid(pid, &status, 0);
58              if (errno == ECHILD)
59                break ;
60           }
61         while (ret != pid);
62
63         if (status == 0)
64           goto restart_e;
65
66         if (!WIFEXITED(status))
67           goto restart_e;
68
69         if (WEXITSTATUS(status) == 1)
70           goto restart_e;
71
72         exit(-11);
73      }
74
75  restart_e:
76    if (getenv("E_START_MTRACK"))
77      e_util_env_set("MTRACK", "track");
78    ecore_app_restart();
79 }
80