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