In my program I put this code for instructs program to spawn a command. This can be used to start another program using a key in my program, such as to spawn firefox. Using program-command run_command “firefox” will have program call system( “firefox &” ).
case RUN_COMMAND:
if( arg ) {
char commandline[ 256 ];
snprintf( commandline, sizeof (commandline), "%s &", arg );
if( cmd->screen ) {
char message[ 256 ];
snprintf( message, sizeof (message), _("Running: %s"), arg );
screen_show_message( cmd->screen, message );
}
system( commandline );
}
break;
When I compile it give this error:
warning: ignoring return value of 'system', declared with attribute warn_unused_result [-Wunused-result]
It means that you shouldn’t assume that
systemwill always succeed. Your code becomes unreliable this way. Appropriate error handling should be in place.