Download this file
34 lines (26 with data), 621 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 | /* SHELL command */
#include "../fb.h"
#include "fb_private_console.h"
#include <sys/wait.h>
int fb_hShell( char *program )
{
int errcode;
FB_LOCK( );
fb_hExitConsole();
FB_UNLOCK( );
errcode = system( program );
/* system() result uses same format as the status
returned by waitpid(), or -1 on error */
if( errcode != -1 && WIFEXITED( errcode ) ) {
errcode = WEXITSTATUS( errcode );
if( errcode == 127 ) {
/* /bin/sh could not be executed */
/* FIXME: can't tell difference if /bin/sh returned 127 */
errcode = -1;
}
}
FB_LOCK( );
fb_hInitConsole();
FB_UNLOCK( );
return errcode;
}
|
×
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.