Apache2에서 execl로 프로세스가 실행이 되지 않는 문제

chaoty의 이미지

개발 환경
우분투 12.04 LTS
Apache2

문제점

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <pthread.h>
 
void *FwCgiSdkTest(void *arg);
 
int main(void)	
{
	char *userAgent;
	userAgent = (char *)malloc(sizeof(getenv("HTTP_USER_AGENT")));
	userAgent = getenv("HTTP_USER_AGENT");
 
	pthread_t threadFwCgiSdk;
	int thread_id;
 
	printf("Content-type: text/html\n\n");
	printf("<!DOCTYPE HTML>\n");
 
	printf("<HTML>\n<HEAD><TITLE>Live Streaming</TITLE></HEAD>\n"
		"<BODY>\n<header>\n<h1>Live Streaming Test Page<h1>\n</header>\n");
 
	if (strstr(userAgent, "iPhone") != NULL || strstr(userAgent, "Mac") != NULL) {
		printf("HLS!\n");
		printf("<video>\n<source src=\"playlist.m3u8\">\n</video>");
	}
	else if (strstr(userAgent, "Chrome") != NULL) {
		printf("DASH!\n");
		thread_id = pthread_create(&threadFwCgiSdk, NULL, FwCgiSdkTest, NULL);	
		//execl("./FwCgiSdkTest", "./FwCgiSdkTest", NULL);
		printf("Error : %d, %s\n", errno, strerror(errno));
		printf("<a href=\"../dash.js-master/index.html\">dash js master</a><br><br>\n");
	}
	else 
		printf("Don't play\n");
	printf("</BODY>\n</HTML>");
	thread_id = pthread_create(&threadFwCgiSdk, NULL, FwCgiSdkTest, NULL);	
	free(userAgent);
	exit(0);
}
 
void *FwCgiSdkTest(void *arg) {
		execl("./FwCgiSdkTest", "./FwCgiSdkTest", NULL);
		return ((void*)0);
}
 

위의 코드가 CGI 코드입니다. 여기서 쓰레드를 사용하여 execl로 FwCgiSdkTest란 프로세스를 호출할려고 합니다.
근데 다른 컴퓨터에서 cgi 프로그램을 실행하면 FwCgiSdkTest가 실행되지 않습니다. 그래서 FwCgiSdkTest만 따로 실행하면 internal server error가 뜹니다.
그리고 cgi-bin 폴더에 접근 할려고 하면 forbidden이 뜨고요. cgi 프로그램도 어쩔 때는 접근이 되고 어쩔 때는 internal server error가 뜹니다.
근데 터미널에서 그냥 실행하면 또 실행이 잘 됩니다. 대체 어떤 문제 때문에 실행이 안되는지 잘 모르겠습니다. 감도 안와요 ㅠㅠ
인터넷에서 검색하니까 접근 권한이 문제가 될 수 있다고 하는데 var 폴더부터 실행 파일까지 전부 755입니다.
어떤 부분을 해결해야 할지 저에게 힌트 좀 주시면 감사하겠습니다 ㅠㅠ

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.