Skip to main content
gamedev.net
🔒 Locked

Start programs in Linux

Started by Zoot Oct 10, 2002 at 2:22 PM 3 replies 850+ views
Original Post
Zoot
Zoot
I am writing a menu program for linux... you can select programs form the menu and everything like that but how do a run a new program? or exec a shell command in c++? I am using g++ with kernal 2.4.19. / Zoot
GSACP: GameDev Society Against Crap PostingTo join: Put these lines in your signature and don't post crap!
necromancer_df
necromancer_df
you need to use the spawn fucntions. try looking at the man page for spawn.
Zoot
Zoot
"No manual entry for spawn"
GSACP: GameDev Society Against Crap PostingTo join: Put these lines in your signature and don't post crap!
Null and Void
Null and Void
Try ''man exec'':

NAME
execl, execlp, execle, execv, execvp - execute a file

SYNOPSIS
#include <unistd.h>

extern char **environ;

int execl(const char *path, const char *arg, ...);
int execlp(const char *file, const char *arg, ...);
int execle(const char *path, const char *arg , ..., char * const
envp[]);
int execv(const char *path, char *const argv[]);
int execvp(const char *file, char *const argv[]);

DESCRIPTION
The exec family of functions replaces the current process image with a
new process image. The functions described in this manual page are
front-ends for the function execve(2). (See the manual page for execve
for detailed information about the replacement of the current process.)

...

You can use them with fork to avoid overwriting your current process. You can use ''system'' too, but I suggest that you don''t if you can avoid it.

necromancer_df
necromancer_df
quote:
Original post by Zoot
"No manual entry for spawn"


yeah sorry about that, i just realised

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.