<HTML ><HEAD ><TITLE >gnome-exec</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.74b"><LINK REL="HOME" TITLE="Gnome Library Reference Manual" HREF="book1.html"><LINK REL="UP" TITLE="Gnome Library" HREF="libgnome.html"><LINK REL="PREVIOUS" TITLE="gnome-dentry" HREF="gnome-gnome-dentry.html"><LINK REL="NEXT" TITLE="gnome-fileconvert" HREF="gnome-gnome-fileconvert.html"></HEAD ><BODY CLASS="REFENTRY" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE WIDTH="100%" BORDER="0" BGCOLOR="#000000" CELLPADDING="1" CELLSPACING="0" ><TR ><TH COLSPAN="4" ALIGN="center" ><FONT COLOR="#FFFFFF" SIZE="5" >Gnome Library Reference Manual</FONT ></TH ></TR ><TR ><TD WIDTH="25%" BGCOLOR="#C00000" ALIGN="left" ><A HREF="gnome-gnome-dentry.html" ><FONT COLOR="#FFFFFF" SIZE="3" ><B ><<< Previous Page</B ></FONT ></A ></TD ><TD WIDTH="25%" BGCOLOR="#0000C0" ALIGN="center" ><FONT COLOR="#FFFFFF" SIZE="3" ><B ><A HREF="book1.html" ><FONT COLOR="#FFFFFF" SIZE="3" ><B >Home</B ></FONT ></A ></B ></FONT ></TD ><TD WIDTH="25%" BGCOLOR="#00C000" ALIGN="center" ><FONT COLOR="#FFFFFF" SIZE="3" ><B ><A HREF="libgnome.html" ><FONT COLOR="#FFFFFF" SIZE="3" ><B >Up</B ></FONT ></A ></B ></FONT ></TD ><TD WIDTH="25%" BGCOLOR="#C00000" ALIGN="right" ><A HREF="gnome-gnome-fileconvert.html" ><FONT COLOR="#FFFFFF" SIZE="3" ><B >Next Page >>></B ></FONT ></A ></TD ></TR ></TABLE ></DIV ><H1 ><A NAME="GNOME-GNOME-EXEC" >gnome-exec</A ></H1 ><DIV CLASS="REFNAMEDIV" ><A NAME="AEN1586" ></A ><H2 >Name</H2 >gnome-exec -- Execution of programs from GNOME applications</DIV ><DIV CLASS="REFSYNOPSISDIV" ><A NAME="AEN1589" ></A ><H2 >Synopsis</H2 ><TABLE BORDER="0" BGCOLOR="#D6E8FF" WIDTH="100%" CELLPADDING="6" ><TR ><TD ><PRE CLASS="SYNOPSIS" > #include <gnome.h> int <A HREF="gnome-gnome-exec.html#GNOME-EXECUTE-ASYNC" >gnome_execute_async</A > (const char *dir, int argc, char *const argv[]); int <A HREF="gnome-gnome-exec.html#GNOME-EXECUTE-ASYNC-FDS" >gnome_execute_async_fds</A > (const char *dir, int argc, char *const argv[], <GTKDOCLINK HREF="GBOOLEAN" >gboolean</GTKDOCLINK > close_fds); int <A HREF="gnome-gnome-exec.html#GNOME-EXECUTE-ASYNC-WITH-ENV" >gnome_execute_async_with_env</A > (const char *dir, int argc, char *const argv[], int envc, char *const envv[]); int <A HREF="gnome-gnome-exec.html#GNOME-EXECUTE-ASYNC-WITH-ENV-FDS" >gnome_execute_async_with_env_fds</A > (const char *dir, int argc, char *const argv[], int envc, char *const envv[], <GTKDOCLINK HREF="GBOOLEAN" >gboolean</GTKDOCLINK > close_fds); int <A HREF="gnome-gnome-exec.html#GNOME-EXECUTE-SHELL" >gnome_execute_shell</A > (const char *dir, const char *commandline); int <A HREF="gnome-gnome-exec.html#GNOME-EXECUTE-SHELL-FDS" >gnome_execute_shell_fds</A > (const char *dir, const char *commandline, <GTKDOCLINK HREF="GBOOLEAN" >gboolean</GTKDOCLINK > close_fds);</PRE ></TD ></TR ></TABLE ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN1601" ></A ><H2 >Description</H2 ><P >The gnome-execute family of functions are provided to simplify execution of programs from withing GNOME applications. These routines are required to avoid passing opened file descriptors to a child process (like the X11 sockets and CORBA sockets). They will also make sure to terminate properly.</P ><P >The range of possibilities goes from the most simple use to the most specialized ones.</P ></DIV ><DIV CLASS="REFSECT1" ><A NAME="AEN1605" ></A ><H2 >Details</H2 ><DIV CLASS="REFSECT2" ><A NAME="AEN1607" ></A ><H3 ><A NAME="GNOME-EXECUTE-ASYNC" ></A >gnome_execute_async ()</H3 ><TABLE BORDER="0" BGCOLOR="#D6E8FF" WIDTH="100%" CELLPADDING="6" ><TR ><TD ><PRE CLASS="PROGRAMLISTING" >int gnome_execute_async (const char *dir, int argc, char *const argv[]);</PRE ></TD ></TR ></TABLE ><P >Like <A HREF="gnome-gnome-exec.html#GNOME-EXECUTE-ASYNC-WITH-ENV" >gnome_execute_async_with_env</A >(), but doesn't add anything to child's environment.</P ><P ></P ><DIV CLASS="INFORMALTABLE" ><A NAME="AEN1614" ></A ><P ></P ><TABLE BORDER="0" WIDTH="100%" BGCOLOR="#FFD0D0" CELLSPACING="0" CELLPADDING="4" CLASS="CALSTABLE" ><TBODY ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><TT CLASS="PARAMETER" ><I >dir</I ></TT > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > Directory in which child should be execd, or NULL for current directory</TD ></TR ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><TT CLASS="PARAMETER" ><I >argc</I ></TT > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > Number of arguments</TD ></TR ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><TT CLASS="PARAMETER" ><I >argv</I ></TT > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > Argument vector to exec child</TD ></TR ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><SPAN CLASS="emphasis" ><I CLASS="EMPHASIS" >Returns</I ></SPAN > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > process id of child, or <TT CLASS="LITERAL" >-1</TT > on error.</TD ></TR ></TBODY ></TABLE ><P ></P ></DIV ></DIV ><HR><DIV CLASS="REFSECT2" ><A NAME="AEN1636" ></A ><H3 ><A NAME="GNOME-EXECUTE-ASYNC-FDS" ></A >gnome_execute_async_fds ()</H3 ><TABLE BORDER="0" BGCOLOR="#D6E8FF" WIDTH="100%" CELLPADDING="6" ><TR ><TD ><PRE CLASS="PROGRAMLISTING" >int gnome_execute_async_fds (const char *dir, int argc, char *const argv[], <GTKDOCLINK HREF="GBOOLEAN" >gboolean</GTKDOCLINK > close_fds);</PRE ></TD ></TR ></TABLE ><P ></P ><P ></P ><DIV CLASS="INFORMALTABLE" ><A NAME="AEN1643" ></A ><P ></P ><TABLE BORDER="0" WIDTH="100%" BGCOLOR="#FFD0D0" CELLSPACING="0" CELLPADDING="4" CLASS="CALSTABLE" ><TBODY ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><TT CLASS="PARAMETER" ><I >dir</I ></TT > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > Directory in which child should be execd, or NULL for current directory</TD ></TR ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><TT CLASS="PARAMETER" ><I >argc</I ></TT > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > Number of arguments</TD ></TR ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><TT CLASS="PARAMETER" ><I >argv</I ></TT > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > Argument vector to exec child</TD ></TR ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><TT CLASS="PARAMETER" ><I >close_fds</I ></TT > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > Like <A HREF="gnome-gnome-exec.html#GNOME-EXECUTE-ASYNC-WITH-ENV-FDS" >gnome_execute_async_with_env_fds</A >(), but doesn't add anything to child's environment.</TD ></TR ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><SPAN CLASS="emphasis" ><I CLASS="EMPHASIS" >Returns</I ></SPAN > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > process id of child, or <TT CLASS="LITERAL" >-1</TT > on error.</TD ></TR ></TBODY ></TABLE ><P ></P ></DIV ></DIV ><HR><DIV CLASS="REFSECT2" ><A NAME="AEN1670" ></A ><H3 ><A NAME="GNOME-EXECUTE-ASYNC-WITH-ENV" ></A >gnome_execute_async_with_env ()</H3 ><TABLE BORDER="0" BGCOLOR="#D6E8FF" WIDTH="100%" CELLPADDING="6" ><TR ><TD ><PRE CLASS="PROGRAMLISTING" >int gnome_execute_async_with_env (const char *dir, int argc, char *const argv[], int envc, char *const envv[]);</PRE ></TD ></TR ></TABLE ><P >This function forks and executes some program in the background. On error, returns <TT CLASS="LITERAL" >-1</TT >; in this case, errno should hold a useful value. Searches the path to find the child. Environment settings in <TT CLASS="PARAMETER" ><I >envv</I ></TT > are added to the existing environment -- they do not completely replace it. This function closes all fds besides 0, 1, and 2 for the child</P ><P ></P ><DIV CLASS="INFORMALTABLE" ><A NAME="AEN1678" ></A ><P ></P ><TABLE BORDER="0" WIDTH="100%" BGCOLOR="#FFD0D0" CELLSPACING="0" CELLPADDING="4" CLASS="CALSTABLE" ><TBODY ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><TT CLASS="PARAMETER" ><I >dir</I ></TT > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > Directory in which child should be execd, or NULL for current directory</TD ></TR ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><TT CLASS="PARAMETER" ><I >argc</I ></TT > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > Number of arguments</TD ></TR ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><TT CLASS="PARAMETER" ><I >argv</I ></TT > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > Argument vector to exec child</TD ></TR ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><TT CLASS="PARAMETER" ><I >envc</I ></TT > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > Number of environment slots</TD ></TR ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><TT CLASS="PARAMETER" ><I >envv</I ></TT > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > Environment vector</TD ></TR ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><SPAN CLASS="emphasis" ><I CLASS="EMPHASIS" >Returns</I ></SPAN > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > the process id, or <TT CLASS="LITERAL" >-1</TT > on error.</TD ></TR ></TBODY ></TABLE ><P ></P ></DIV ></DIV ><HR><DIV CLASS="REFSECT2" ><A NAME="AEN1708" ></A ><H3 ><A NAME="GNOME-EXECUTE-ASYNC-WITH-ENV-FDS" ></A >gnome_execute_async_with_env_fds ()</H3 ><TABLE BORDER="0" BGCOLOR="#D6E8FF" WIDTH="100%" CELLPADDING="6" ><TR ><TD ><PRE CLASS="PROGRAMLISTING" >int gnome_execute_async_with_env_fds (const char *dir, int argc, char *const argv[], int envc, char *const envv[], <GTKDOCLINK HREF="GBOOLEAN" >gboolean</GTKDOCLINK > close_fds);</PRE ></TD ></TR ></TABLE ><P >Like <A HREF="gnome-gnome-exec.html#GNOME-EXECUTE-ASYNC-WITH-ENV" >gnome_execute_async_with_env</A >() but has a flag to decide whether or not * to close fd's</P ><P ></P ><DIV CLASS="INFORMALTABLE" ><A NAME="AEN1716" ></A ><P ></P ><TABLE BORDER="0" WIDTH="100%" BGCOLOR="#FFD0D0" CELLSPACING="0" CELLPADDING="4" CLASS="CALSTABLE" ><TBODY ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><TT CLASS="PARAMETER" ><I >dir</I ></TT > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > Directory in which child should be execd, or NULL for current directory</TD ></TR ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><TT CLASS="PARAMETER" ><I >argc</I ></TT > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > Number of arguments</TD ></TR ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><TT CLASS="PARAMETER" ><I >argv</I ></TT > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > Argument vector to exec child</TD ></TR ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><TT CLASS="PARAMETER" ><I >envc</I ></TT > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > Number of environment slots</TD ></TR ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><TT CLASS="PARAMETER" ><I >envv</I ></TT > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > Environment vector</TD ></TR ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><TT CLASS="PARAMETER" ><I >close_fds</I ></TT > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > If TRUE will close all fds but 0,1, and 2</TD ></TR ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><SPAN CLASS="emphasis" ><I CLASS="EMPHASIS" >Returns</I ></SPAN > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > the process id, or <TT CLASS="LITERAL" >-1</TT > on error.</TD ></TR ></TBODY ></TABLE ><P ></P ></DIV ></DIV ><HR><DIV CLASS="REFSECT2" ><A NAME="AEN1750" ></A ><H3 ><A NAME="GNOME-EXECUTE-SHELL" ></A >gnome_execute_shell ()</H3 ><TABLE BORDER="0" BGCOLOR="#D6E8FF" WIDTH="100%" CELLPADDING="6" ><TR ><TD ><PRE CLASS="PROGRAMLISTING" >int gnome_execute_shell (const char *dir, const char *commandline);</PRE ></TD ></TR ></TABLE ><P >Like <A HREF="gnome-gnome-exec.html#GNOME-EXECUTE-ASYNC-WITH-ENV" >gnome_execute_async_with_env</A >(), but uses the user's shell to run the desired program. Note that the pid of the shell is returned, not the pid of the user's program.</P ><P ></P ><DIV CLASS="INFORMALTABLE" ><A NAME="AEN1757" ></A ><P ></P ><TABLE BORDER="0" WIDTH="100%" BGCOLOR="#FFD0D0" CELLSPACING="0" CELLPADDING="4" CLASS="CALSTABLE" ><TBODY ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><TT CLASS="PARAMETER" ><I >dir</I ></TT > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > Directory in which child should be execd, or NULL for current directory</TD ></TR ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><TT CLASS="PARAMETER" ><I >commandline</I ></TT > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > Shell command to execute</TD ></TR ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><SPAN CLASS="emphasis" ><I CLASS="EMPHASIS" >Returns</I ></SPAN > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > process id of shell, or <TT CLASS="LITERAL" >-1</TT > on error.</TD ></TR ></TBODY ></TABLE ><P ></P ></DIV ></DIV ><HR><DIV CLASS="REFSECT2" ><A NAME="AEN1775" ></A ><H3 ><A NAME="GNOME-EXECUTE-SHELL-FDS" ></A >gnome_execute_shell_fds ()</H3 ><TABLE BORDER="0" BGCOLOR="#D6E8FF" WIDTH="100%" CELLPADDING="6" ><TR ><TD ><PRE CLASS="PROGRAMLISTING" >int gnome_execute_shell_fds (const char *dir, const char *commandline, <GTKDOCLINK HREF="GBOOLEAN" >gboolean</GTKDOCLINK > close_fds);</PRE ></TD ></TR ></TABLE ><P ></P ><P ></P ><DIV CLASS="INFORMALTABLE" ><A NAME="AEN1782" ></A ><P ></P ><TABLE BORDER="0" WIDTH="100%" BGCOLOR="#FFD0D0" CELLSPACING="0" CELLPADDING="4" CLASS="CALSTABLE" ><TBODY ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><TT CLASS="PARAMETER" ><I >dir</I ></TT > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > Directory in which child should be execd, or NULL for current directory</TD ></TR ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><TT CLASS="PARAMETER" ><I >commandline</I ></TT > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > Shell command to execute</TD ></TR ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><TT CLASS="PARAMETER" ><I >close_fds</I ></TT > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > Like close_fds in <A HREF="gnome-gnome-exec.html#GNOME-EXECUTE-ASYNC-WITH-ENV-FDS" >gnome_execute_async_with_env_fds</A >() Like <A HREF="gnome-gnome-exec.html#GNOME-EXECUTE-ASYNC-WITH-ENV-FDS" >gnome_execute_async_with_env_fds</A >(), but uses the user's shell to run the desired program. Note that the pid of the shell is returned, not the pid of the user's program.</TD ></TR ><TR ><TD WIDTH="20%" ALIGN="RIGHT" VALIGN="TOP" ><SPAN CLASS="emphasis" ><I CLASS="EMPHASIS" >Returns</I ></SPAN > :</TD ><TD WIDTH="80%" ALIGN="LEFT" VALIGN="TOP" > process id of shell, or <TT CLASS="LITERAL" >-1</TT > on error.</TD ></TR ></TBODY ></TABLE ><P ></P ></DIV ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><BR CLEAR="all"><BR><TABLE WIDTH="100%" BORDER="0" BGCOLOR="#000000" CELLPADDING="1" CELLSPACING="0" ><TR ><TD WIDTH="25%" BGCOLOR="#C00000" ALIGN="left" ><A HREF="gnome-gnome-dentry.html" ><FONT COLOR="#FFFFFF" SIZE="3" ><B ><<< Previous Page</B ></FONT ></A ></TD ><TD WIDTH="25%" BGCOLOR="#0000C0" ALIGN="center" ><FONT COLOR="#FFFFFF" SIZE="3" ><B ><A HREF="book1.html" ><FONT COLOR="#FFFFFF" SIZE="3" ><B >Home</B ></FONT ></A ></B ></FONT ></TD ><TD WIDTH="25%" BGCOLOR="#00C000" ALIGN="center" ><FONT COLOR="#FFFFFF" SIZE="3" ><B ><A HREF="libgnome.html" ><FONT COLOR="#FFFFFF" SIZE="3" ><B >Up</B ></FONT ></A ></B ></FONT ></TD ><TD WIDTH="25%" BGCOLOR="#C00000" ALIGN="right" ><A HREF="gnome-gnome-fileconvert.html" ><FONT COLOR="#FFFFFF" SIZE="3" ><B >Next Page >>></B ></FONT ></A ></TD ></TR ><TR ><TD COLSPAN="2" ALIGN="left" ><FONT COLOR="#FFFFFF" SIZE="3" ><B >gnome-dentry</B ></FONT ></TD ><TD COLSPAN="2" ALIGN="right" ><FONT COLOR="#FFFFFF" SIZE="3" ><B >gnome-fileconvert</B ></FONT ></TD ></TR ></TABLE ></DIV ></BODY ></HTML >