Ownership for a short lifetime string.

This commit is contained in:
2025-04-19 02:08:30 -04:00
parent 918a283748
commit efb891d82e

View File

@ -37,7 +37,7 @@ int main(void)
{
FILE *in_stream;
Dsh *sh;
char *dpip_tag, *cmd = NULL, *url = NULL, *child_cmd = NULL;
char *dpip_tag, *cmd = NULL, *url = NULL;
char *esc_tag, *d_cmd;
size_t n;
int ret;
@ -150,11 +150,11 @@ int main(void)
* (An example of generating dynamic content with an external
* program). */
if (cmd && url) {
child_cmd = dStrdup("date -R");
MSG("[%s]\n", child_cmd);
std::string child_cmd = "date -R";
MSG("[%s]\n", child_cmd.c_str());
/* Fork, exec command, get its output and answer */
if ((in_stream = popen(child_cmd, "r")) == NULL) {
if ((in_stream = popen(child_cmd.c_str(), "r")) == NULL) {
perror("popen");
return EXIT_FAILURE;
}
@ -171,8 +171,6 @@ int main(void)
if ((ret = pclose(in_stream)) != 0)
MSG("popen: [%d]\n", ret);
dFree(child_cmd);
}
a_Dpip_dsh_write_str(sh, 1, "</body></html>\n");