Search Results

Search found 3 results on 1 pages for 'alexxx'.

Page 1/1 | 1 

  • forkpty - socket

    - by Alexxx
    Hi, I'm trying to develop a simple "telnet/server" daemon which have to run a program on a new socket connection. This part working fine. But I have to associate my new process to a pty, because this process have some terminal capabilities (like a readline). The code I've developped is (where socketfd is the new socket file descriptor for the new input connection) : int masterfd, pid; const char *prgName = "..."; char *arguments[10] = ....; if ((pid = forkpty(&masterfd, NULL, NULL, NULL)) < 0) perror("FORK"); else if (pid) return pid; else { close(STDOUT_FILENO); dup2(socketfd, STDOUT_FILENO); close(STDIN_FILENO); dup2(socketfd, STDIN_FILENO); close(STDERR_FILENO); dup2(socketfd, STDERR_FILENO); if (execvp(prgName, arguments) < 0) { perror("execvp"); exit(2); } } With that code, the stdin / stdout / stderr file descriptor of my "prgName" are associated to the socket (when looking with ls -la /proc/PID/fd), and so, the terminal capabilities of this process doesn't work. A test with a connection via ssh/sshd on the remote device, and executing "localy" (under the ssh connection) prgName, show that the stdin/stdout/stderr fd of this process "prgName" are associated to a pty (and so the terminal capabilities of this process are working fine). What I am doing wrong? How to associate my socketfd with the pty (created by forkpty) ? Thank Alex

    Read the article

  • excel number format - varying decimal digits

    - by Alexxx
    I'm trying to set a special cell number format with theses rules: display percentage display at max 3 digits (decimal + integer part) So I can display 100% or 99.3% or 1.27% but not 100.9% or 100.27% or 99.27%. Of course, I can have negative number (-27.3%) and it does not affect my rules. I've try with the cell formating option without success: [<1]0.00%;[<10]0.0%;0% Because it seemed that excel (2010) does not support more than 2 conditions in cell formating (and so I can't expand it to manage negative number...) It there anyway to do what I want? Thanks

    Read the article

  • Unreasonable errors in merge sort

    - by Alexxx
    i have the following errors - please help me to find the error: 9 IntelliSense: expected a '}' 70 4 it points on the end of the code - but there are no open { anywhere!! so why?? 8 IntelliSense: expected a ';' 57 1 it points on the { after the void main but why to put ; after the { of the void main?? Error 7 error C1075: end of file found before the left brace '{' at 70 1 points to the beginig of the code - why??? #include <stdio.h> #include <stdlib.h> void merge(int *a,int p,int q,int r) { int i=p,j=q+1,k=0; int* temp=(int*)calloc(r-p+1, sizeof(int)); while ((i<=q)&& (j<=r)) if(a[i]<a[j]) temp[k++]=a[i++]; else temp[k++]=a[j++]; while(j<=r) // if( i>q ) temp[k++]=a[j++]; while(i<=q) // j>r temp[k++]=a[i++]; for(i=p,k=0;i<=r;i++,k++) // copy temp[] to a[] a[i]=temp[k]; free(temp); } void merge_sort(int *a,int first, int last) { int middle; if(first < last) { middle=(first+last)/2; merge_sort(a,first,middle); merge_sort(a,middle+1,last); merge(a,first,middle,last); { } void main() { int a[] = {9, 7, 2, 3, 5, 4, 1, 8, 6, 10}; int i; merge_sort(a, 0, 9); for (i = 0; i < 10; i++) printf ("%d ", a[i]);

    Read the article

1