Fix failed execvp notifycmd
This commit is contained in:
parent
f1fe73aff8
commit
58d1470890
3
TODO
3
TODO
|
@ -1,6 +1,3 @@
|
||||||
1. Add more support for non-libnotify such as echo(1)
|
|
||||||
2. Pause and continue the timer
|
|
||||||
|
|
||||||
Misc
|
Misc
|
||||||
----
|
----
|
||||||
$ grep -n 'TODO' spt.c
|
$ grep -n 'TODO' spt.c
|
||||||
|
|
29
spt.c
29
spt.c
|
@ -14,7 +14,15 @@
|
||||||
char *argv0;
|
char *argv0;
|
||||||
|
|
||||||
/* macros */
|
/* macros */
|
||||||
#define LEN(a) (sizeof(a) / sizeof(a[0]))
|
#define LEN(a) (sizeof(a) / sizeof(a[0]))
|
||||||
|
#define SPAWN(cmd) if (fork() == 0) {\
|
||||||
|
setsid();\
|
||||||
|
cmd;\
|
||||||
|
die("spt: spawn\n");\
|
||||||
|
perror(" failed");\
|
||||||
|
exit(0);\
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned int tmr;
|
unsigned int tmr;
|
||||||
|
@ -27,7 +35,6 @@ static int i, timecount;
|
||||||
|
|
||||||
/* function declarations */
|
/* function declarations */
|
||||||
static void die(const char *errstr, ...);
|
static void die(const char *errstr, ...);
|
||||||
static void spawn(char *cmd, char *cmt);
|
|
||||||
static void notify_send(char *cmt);
|
static void notify_send(char *cmt);
|
||||||
static void remaining_time(int sigint);
|
static void remaining_time(int sigint);
|
||||||
static void usage(void);
|
static void usage(void);
|
||||||
|
@ -44,18 +51,6 @@ die(const char *errstr, ...)
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
spawn(char *cmd, char *cmt)
|
|
||||||
{
|
|
||||||
if (fork() == 0) {
|
|
||||||
setsid();
|
|
||||||
execvp("sh", (char *const []){"/bin/sh", "-c", cmd, cmt, NULL});
|
|
||||||
fprintf(stderr, "spt: execvp %s", cmd);
|
|
||||||
perror(" failed"); /* 2 errors report? */
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
notify_send(char *cmt)
|
notify_send(char *cmt)
|
||||||
{
|
{
|
||||||
|
@ -67,12 +62,12 @@ notify_send(char *cmt)
|
||||||
g_object_unref(G_OBJECT(n));
|
g_object_unref(G_OBJECT(n));
|
||||||
notify_uninit();
|
notify_uninit();
|
||||||
#else
|
#else
|
||||||
if (strcmp(notifycmd, ""))
|
if (strcmp(notifycmd, "")) /* TODO: call function in config.h */
|
||||||
spawn(notifycmd, cmt);
|
SPAWN(execlp(notifycmd, notifycmd, "spt", cmt, NULL))
|
||||||
#endif /* NOTIFY */
|
#endif /* NOTIFY */
|
||||||
|
|
||||||
if (strcmp(notifyext, "")) /* extra commands to use */
|
if (strcmp(notifyext, "")) /* extra commands to use */
|
||||||
spawn(notifyext, NULL);
|
SPAWN(execvp("sh", (char *const []){"/bin/sh", "-c", notifyext, NULL}))
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in New Issue
Block a user