🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.os.linux.programacion
Article #7199

Curses y fork

#7199
From: xsidius
Date: Sat, 29 Mar 2003 15:12
63 lines
2678 bytes
Estoy haciendo un practiquilla cliente/servidor para ello uso las
curses, la practiquilla lo que tengo que hacer es tipo chat. 

En mitad superior de la terminal imprimo los mensajes que me llegan
del servidor y en la mitad inferior pues hago interfaz con el usuario.

La cosa es que hago un fork y las dos ventanas de las curses se hacen
la picha un lio. Como en este ejemplo:


#include <unistd.h>
#include <curses.h>
#include <sys/types.h>
#include <signal.h>

int main() {
    pid_t pid; /*Control de procesos padre-hijo*/
    /* initialize curses */
    WINDOW *msn_server;
    WINDOW *interfaz;

    interfaz=subwin(stdscr, LINES/2-1, COLS, LINES/2 +1, 0);
    msn_server=subwin(stdscr, LINES/2-1, COLS, 0, 0);
    initscr();

    pid=fork();
    if (pid==-1)
        perror("creando hijo:");
    else if (pid==0){
        /*codigo del hijo*/
           wprintw(msn_server, "Lineas %d y Columnas %d", LINES,COLS);
           wrefresh(msn_server);
        
    }
    else {    
	
	  wprintw(interfaz, "Este ejemplo es una mierda" );
      wrefresh(interfaz);

      delwin(interfaz);
      delwin(msn_server);
      touchwin(stdscr);
      refresh();
      sleep(2);
      endwin();
      kill(pid, SIGKILL);
      exit(0);
    }

}



�Alguien me ayuda?


-- 
Homer: Tengo la mano atrapada en la m�quina
Operario: �Has probado a soltar la cerveza?
-------------------------------------------
David Hern�ndez <dahernan@telecable.es>
xsidius		<xsidius@escomposlinux.org>
-------------------------------------------
Technical Details
Message-ID: <slrnb8bdv2.4on.xsidius@dhp.net.dhis.org>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!nntp.theplanet.net!inewsm1.nntp.theplanet.net!zen.net.uk!btnet-peer1!btnet-peer0!btnet-peer!btnet!newsfeed.bt.es!newsfeed.telecable.es!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII
X-Google-Thread: f86c8,602a08c6d66c5bcf,start
X-Google-Attributes: gidf86c8,public
X-Google-ArrivalTime: 2003-03-29 07:16:48 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!nntp.theplanet.net!inewsm1.nntp.theplanet.net!zen.net.uk!btnet-peer1!btnet-peer0!btnet-peer!btnet!newsfeed.bt.es!newsfeed.telecable.es!not-for-mail
From: xsidius <xsidius@escomposlinux.org>
Newsgroups: es.comp.os.linux.programacion
Subject: Curses y fork
Date: Sat, 29 Mar 2003 15:12:33 +0000 (UTC)
Organization: Telecable S.A.
Lines: 64
Message-ID: <slrnb8bdv2.4on.xsidius@dhp.net.dhis.org>
NNTP-Posting-Host: cmr-212-89-9-132.telecable.es
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: filemon1.isp.telecable.es 1048950753 5395 212.89.9.132 (29 Mar 2003 15:12:33 GMT)
X-Complaints-To: abuse@telecable.es
NNTP-Posting-Date: Sat, 29 Mar 2003 15:12:33 +0000 (UTC)
User-Agent: slrn/0.9.7.4 (Linux)