GRASS 8 Programmer's Manual 8.6.0dev(2026)-08f30e8994
Loading...
Searching...
No Matches
popen.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <grass/gis.h>
#include <grass/spawn.h>
Include dependency graph for popen.c:

Go to the source code of this file.

Functions

void G_popen_clear (struct Popen *state)
 
FILEG_popen_write (struct Popen *state, const char *program, const char **args)
 
FILEG_popen_read (struct Popen *state, const char *program, const char **args)
 
int G_popen_close (struct Popen *state)
 Closes a pipe opened with G_popen_read() or G_popen_write().
 

Function Documentation

◆ G_popen_clear()

void G_popen_clear ( struct Popen state)

Definition at line 56 of file popen.c.

References UntypedStream::fp, NULL, and state.

Referenced by G_open_mail(), G_open_pager(), and G_popen_close().

◆ G_popen_close()

int G_popen_close ( struct Popen state)

Closes a pipe opened with G_popen_read() or G_popen_write().

Closes the associated stream, waits for the spawned process to finish, clears the popen state, and returns the process status reported by G_wait(). If the state has no open stream or process, it is cleared and 0 is returned.

Parameters
statePointer to the popen state to close and reset.
Returns
The status returned by G_wait(), or 0 when no process is associated with the state.

Definition at line 84 of file popen.c.

References UntypedStream::fp, G_popen_clear(), G_wait(), and state.

Referenced by G_close_mail(), and G_close_pager().

◆ G_popen_read()

FILE * G_popen_read ( struct Popen state,
const char program,
const char **  args 
)

Definition at line 67 of file popen.c.

References state.

◆ G_popen_write()

FILE * G_popen_write ( struct Popen state,
const char program,
const char **  args 
)

Definition at line 62 of file popen.c.

References state.

Referenced by G_open_mail(), and G_open_pager().