Project Home
Project Home
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
BroadcastCommunity.qnx.com will be offline from May 31 6:00pm until June 2 12:00AM for upcoming system upgrades. For more information please go to https://community.qnx.com/sf/discussion/do/listPosts/projects.bazaar/discussion.bazaar.topc28418
Forum Topic - Porting of a web gui from QNX 6.3.2 to QNX 6.4.1 using Slinger Web Server: (4 Items)
   
Porting of a web gui from QNX 6.3.2 to QNX 6.4.1 using Slinger Web Server  
Hi,
i'm making a porting of a web gui from QNX 6.3.2 to QNX 6.4.1 using Slinger Web Server and C CGI Scripts running on it 
and i've found a problem.

I'm not using the SSI token in the shtml files, but C programs (C CGI Scripts) that create dinamycally html pages.

Working on QNX 6.4.1 ,when i make a system() call, from a C CGI Scripts, the system launchs the command and executes it 
correctly, but the return value is -1 and the results of the command is displayed on the web window, while, on QNX 6.3.2
 the return value is 0 and the results of the command is not displayed on the web window.
If the same C CGI Scripts is launched from command line, it works always correctly.

If i make change the user that execute the C CGI via Slinger, from Slinger user, that is root -2 (with uid 4294967294 ),
 to user.users, it fails the same.
While, from shell, if i execute it with Slinger user, setting uid at 4294967294, it works always correctly. So it seems 
that does not depends on the user.

The same happens if, instead of a system(), i use a spawn() or a spawnl() or a execl() or a execvp(). Also if i use a 
fork() with an execl(). If i test waitpid(), its return value is always -1.

The WIFEXITED(sysStatus) and WEXITSTATUS( sysStatus ) macros confirm the error, that is always: errno = 10 and 
strerror(errno)="No child processes".

I've implemented the QNX 6.4.1 system() code, calling it "mysystem()" and adding some logs inside to see what happens. I
 discovered that, when the QNX 6.4.1 system() tests the waitpid() return value, being it always -1, the system() returns
 always -1 too.

Analyzing it with "pidin fam sig" command, it seems that when i launch from Slinger a C CGI Scripts, with his own PID, 
and this C CGI Scripts 'spawns' a process, with his own PID, the parent-child relationship between them is no more 
present.
And so, the C CGI Scripts wrongly thinks that has no wait for any child processes.

How can i resolve this problem?


Below there is the Slinger launch command script:

/home/user/riccardoa# cat /etc/rc.d/rc.www

#!/bin/sh

#ifdef __USAGE
#
#%C
#
# It starts http server for this system
#
#endif

export HTTPD_ROOT_DIR=/lsu/www/current
export HTTPD_ROOT_DOC=index.html
export HTTPD_SCRIPTALIAS=/lsu/www/current/cgi

slay -Q slinger
slinger -d -c -e -s

# eof


Below there are the Slinger launch command script privileges:

/home/user/riccardoa# ls -la /etc/rc.d/rc.www

-rwxr-xr-x  1 root      root            253 Mar 16  2006 /etc/rc.d/rc.www




Below there is a simple C CGI Scripts example that works on QNX 6.3.2, but doesn't on QNX 6.4.1:


#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <sys/wait.h>

int main (int argc, char *argv[])
{
   	int sysStatus = 0;

	printf("Content-type: text/html;\n\n");
	
	sysStatus = system( "/usr/bin/id " );


      if( sysStatus == -1 ) {
         printf( "<!-- shell could not be run -->\n" );
      } else {
         printf( "<!-- OK result of the system() is %d  -->\n", WEXITSTATUS( sysStatus ) );
      }

	return 0;
}


Below there are the C CGI Scripts example privileges:

-rwsr-sr-x  1 root      root           5255 Mar 31 18:00 cgiTestSystemCall-1.0


Best regards.

Riccardo Annolfi

Re: Porting of a web gui from QNX 6.3.2 to QNX 6.4.1 using Slinger Web Server  
Below there is a html page that call the C CGI Scripts example of the previous post:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
	<head>
   	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
	<META HTTP-EQUIV="pragma" CONTENT="no-cache">
   	<meta name="Owner" content="PRISMA ENGINEERING S.r.l.">
   	<meta name="Author" content="Riccardo ANNOLFI">
   	<title>Archive : steroidi</title>
<script language="JavaScript">
<!--
function MM_goToURL() { //v3.0
	var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
	for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  winName=window.open(theURL,winName,features);
  winName.creator=self;
  winName.focus();
}
//-->
</script>
</head>
<body>
	  <a href="#" onClick="MM_openBrWindow('/cgi-bin/cgiTestSystemCall','cgiTestSystemCall','status=yes,scrollbars=no,
resizable=no,width=450,height=245');"> clickMe </a>
</body>
</html>

Best regards.

Riccardo Annolfi
Re: Porting of a web gui from QNX 6.3.2 to QNX 6.4.1 using Slinger Web Server  
Hi,
How are you?

I have a question.

I have same problem of you with slinger. have you solved the problem?

Can you answer me please it's for my graduate work and it's very important for me.

Thank you very much.
Re: Porting of a web gui from QNX 6.3.2 to QNX 6.4.1 using Slinger Web Server  
Hello,

I realize this is a bit late but figured I'd answer it anyway in case anyone else needs to know.

The reason it's happening is that slinger ignores SIGCHLD.  If you want your cgi program to be able to spawn and then 
grab the return value, you need to stop ignoring SIGCHLD:

signal(SIGCHLD,SIG_DFL);  // Set SIGCHLD back to default

Cheers,

Matt M