MCPcopy Create free account
hub / github.com/Motion-Project/motion / exec_command

Function exec_command

src/event.c:83–104  ·  view source on GitHub ↗

* exec_command * Execute 'command' with 'arg' as its argument. * if !arg command is started with no arguments * Before we call execl we need to close all the file handles * that the fork inherited from the parent in order not to pass * the open handles on to the shell */

Source from the content-addressed store, hash-verified

81 * the open handles on to the shell
82 */
83static void exec_command(struct context *cnt, char *command, char *filename, int filetype)
84{
85 char stamp[PATH_MAX];
86 mystrftime(cnt, stamp, sizeof(stamp), command, &cnt->current_image->timestamp_tv, filename, filetype);
87
88 if (!fork()) {
89
90 /* Detach from parent */
91 setsid();
92
93 execl("/bin/sh", "sh", "-c", stamp, " &", NULL);
94
95 /* if above function succeeds the program never reach here */
96 MOTION_LOG(ALR, TYPE_EVENTS, SHOW_ERRNO
97 ,_("Unable to start external command '%s'"), stamp);
98
99 exit(1);
100 }
101
102 MOTION_LOG(DBG, TYPE_EVENTS, NO_ERRNO
103 ,_("Executing external command '%s'"), stamp);
104}
105
106/*
107 * Event handlers

Callers 8

on_picture_save_commandFunction · 0.85
on_area_commandFunction · 0.85
on_event_start_commandFunction · 0.85
on_event_end_commandFunction · 0.85
event_camera_lostFunction · 0.85
event_camera_foundFunction · 0.85
on_movie_end_commandFunction · 0.85

Calls 1

mystrftimeFunction · 0.85

Tested by

no test coverage detected