Penggunaan fungsi FORKINH pada PHP

12.10.2009

FreeBSD security officer Colin Percival confirmed the issue could allow a local user to execute arbitrary code as root.  It affects FreeBSD versions 7.1 and 8.0. nah buat elo2 yg punya server freebsd 7.x sampe 8.0, mendingan cepet2 di patch deh. karena ada exploit dari zeroday yang direlease akhir november 2009 kemaren. Simple explanation of […]

12.09.2009

Pengen download video dari youtube? ngapain susah. nih gue kasih demo nya buat elo2 pada pake php. DEMO dan download script dapat dilihat di sini. <?php /* * youtube url downloader v0.2 – after youtube upgrade 29 agustus 2009 * * by lemonade <> * donation is very appreciated, paypal:  * * * ChangeLog * * v0.2 * 27/10/2009 – new parsing for youtube. * * v0.1 * 25/09/2009 – small fix for FLV url. * */ if(!empty($_REQUEST[‘yid’])) { $yid = trim($_REQUEST[‘yid’]); $yid = urldecode(rawurldecode($yid)); if (preg_match(‘%http://www.youtube.com/watch?v=(.*)%s’, $yid, $regs)) { […]

11.15.2009

HTTP Request – web browser atau http client merequest/mensubmit file/data ke server. HTTP Response – data yang dikirimkan kembali dari webserver terhadap web browser atau http client menjawab http request nya. Contoh, simple html form yang menggunakan jsp untuk validasi jawaban dari 5 + 5 File: form01.jsp <%@page contentType=”text/html” pageEncoding=”UTF-8″%> <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML […]

11.05.2009

Contoh client-server chatting (single client) menggunakan PHP socket. Server.php <?php //The Server error_reporting(E_ALL); $address = “127.0.0.1”; $port = “10000”; /* create a socket in the AF_INET family, using SOCK_STREAM for TCP connection */ $mysock = socket_create(AF_INET, SOCK_STREAM, 0); // if socket is uses, we reuse it if (!socket_set_option($mysock, SOL_SOCKET, SO_REUSEADDR, 1)) { echo socket_strerror(socket_last_error($mysock)); exit; […]

11.01.2009

TCP Fungsi – Socket adalah 1 endpoint dari communication link antara 2 program di dalam sebuah network. Sebuah socket pasti memiliki sebuah port supaya TCP layer dapat meng-identifikasi aplikasi mana yg akan mengirim atau menerima data. UDP Fungsi – Datagram communication atau yang di kenal dengan UDP, adalah connectionless protocol, yang artiinya tidak dibutuhkan handshaking […]

10.30.2009

•   HTTP – Hypertext Transfer Protocol Fungsi – HTTP adalah appliation-level protocol yang kebanyakan digunakan untuk aplikasi world wide web. Cara Kerja – Port standard HTTP adalah port 80 (pada server). – http adalah application level protocol client-server yang menggunakan request/response method. – Web server menunggu connection dari web browser (http client) untuk meminta request […]

10.27.2009

simple.c – download link // named pipe // Firman Gautama #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/wait.h> #include <sys/types.h> #include <sys/stat.h> #include <string.h> int main(void) { int p, check, nilai; FILE *fp; // sebelum fork system(“clear”); check = mkfifo(“pipe”, 0666); if(check < 0) {   printf(“pipe gagaln”); exit(0); } // forking stuff p = fork(); […]

10.27.2009

simple.c – download link // unnamed pipe // Firman Gautama #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/wait.h> #include <sys/types.h> #include <string.h> int main(void) { int p, blah[2], check; int nilai; // sebelum fork check = pipe(blah); if(check < 0) {   printf(“pipe gagaln”); exit(0); } system(“clear”); // forking stuff p = fork(); if(p < 0) […]

10.19.2009

Session adalah temporary variable yang dibuat oleh server side scripting, oleh sebab itu javascript (client side scripting)tidak bisa membaca session/menulis secara directly tanpa bantuan server side scripting. Contoh session javascript + php: (http://download.indolayer.com/tmp/test1.php) <?php // test1.php session_start(); $_SESSION[‘dodol’] = “apa aja deh”; ?> <html> <head> <title> test session </title> </head> <body> <script type=”text/javascript”> var apple_s […]

  • Ubuntu 9.10 / CentOS 5.5
  • PHP 5.2.10-2ubuntu6.7 / 5.2.11

The following minimal testcase gives this output:

string(3) "foo"

Warning: stat() [function.stat]: stat failed for Resource id #3 in /[...]/mkfifo.php on line 10

bool(false)

<?php

$pipe_name = 'foo';
if(!file_exists($pipe_name) && !posix_mkfifo($pipe_name, 0777)){
  echo 'foo';
  exit(1);
}
var_dump($pipe_name);
$pipe = fopen($pipe_name, 'r+');
var_dump(stat($pipe));

?>

Surely I'm doing something wrong? I used r+ because it's supposedly "works for me" per http://php.net/manual/en/function.posix-mkfifo.php#89642 but as you can see I don't even get a chance to do the non-blocking part. Alternative, more verbose solution that I haven't tried yet: http://php.net/manual/en/function.shell-exec.php#52826

Penggunaan fungsi FORKINH pada PHP

hakre

187k48 gold badges418 silver badges802 bronze badges

asked Mar 15, 2011 at 18:44

I think your error is soleley caused by using stat() there. You give it an opened file resource, but it should be used with a $filename only.

Your pipe was correctly opened as evidenced by Resource id #3

Use stat($pipe_name) to get informations about the fifo.
Or stream_get_meta_data($pipe) for the opened file handle.

answered Mar 15, 2011 at 18:50

mariomario

142k20 gold badges236 silver badges285 bronze badges

0

Not the answer you're looking for? Browse other questions tagged php file-io named-pipes or ask your own question.