Fun 0.41.5
The programming language that makes You have fun
Loading...
Searching...
No Matches
proc_run.c File Reference

Implements OP_PROC_RUN to execute a shell command and capture stdout. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for proc_run.c:

Go to the source code of this file.

Functions

 free_value (cmdv)
 if (!cmd)
 if (fp)
map_setm (out ? out :"")
map_setm (exit_code)
 push_value (vm, m)
 free (cmd)

Variables

case OP_PROC_RUN
char * cmd = value_to_string_alloc(&cmdv)
FILE * fp = popen(cmd, "r")
int exit_code = -1
char * out = NULL
size_t cap = 0
size_t len = 0
 else
Value m = make_map_empty()
done_push __pad0__
 break

Detailed Description

Implements OP_PROC_RUN to execute a shell command and capture stdout.

Behavior:

  • Pops command (string); runs it via the platform shell; pushes a map {"out": string, "code": int}.
  • "code" is the process exit status if available, otherwise -1.

Errors:

  • On allocation failures or popen errors, returns {out: "", code: -1}.

Definition in file proc_run.c.

Function Documentation

◆ free()

free(cmd)
Here is the caller graph for this function:

◆ free_value()

free_value(cmdv)

◆ if() [1/2]

if(!cmd)

Definition at line 35 of file proc_run.c.

Here is the call graph for this function:

◆ if() [2/2]

if(fp)

Definition at line 48 of file proc_run.c.

Here is the call graph for this function:

◆ m() [1/2]

◆ m() [2/2]

map_set & m(out ? out :"")

◆ push_value()

push_value(vm,
m )
Here is the caller graph for this function:

Variable Documentation

◆ __pad0__

done_push __pad0__

Definition at line 99 of file proc_run.c.

◆ break

break

Definition at line 102 of file proc_run.c.

◆ cap

size_t cap = 0

Definition at line 47 of file proc_run.c.

◆ cmd

char* cmd = value_to_string_alloc(&cmdv)

Definition at line 33 of file proc_run.c.

◆ else

else
Initial value:
{
out = strdup("")
Value out
Definition apop.c:38

Definition at line 89 of file proc_run.c.

◆ exit_code

exit_code = -1

Definition at line 45 of file proc_run.c.

◆ fp

FILE* fp = popen(cmd, "r")

Definition at line 44 of file proc_run.c.

◆ len

size_t len = 0

Definition at line 47 of file proc_run.c.

◆ m

Definition at line 94 of file proc_run.c.

◆ OP_PROC_RUN

case OP_PROC_RUN

Definition at line 30 of file proc_run.c.

◆ out

char* out = NULL

Definition at line 46 of file proc_run.c.