[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Noob libssh question


I am using libssl to execute simple C programs between raspberry pi's.
These programs are simple SDL graphics applications similar to that listed
below that don't write anything to stderr (unless there is an error) or

I am also doing some remote file creation and deletion using the same
libssl functionality.

When I remotely execute commands such as "touch runfile" or "rm runfile" I
can see 0 bytes are returned from ssh_channel_read function as would be
expected. However whenever I run one of my little C programs
ssh_channel_read always returns -2 but the program runs successfully on the
remote system.

Is there something I need to do in my C programs to satisfy

Thanks for looking

 * A Smart Screen Module
 * Sets the entire screen to a specified RGB color
 * Typical Call:
 *      colorscreen 0 255 0
 * Concept and Implementation by: Craig A. Lindley
 * Last Update: 01/30/2014

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>

#include "SDL/SDL.h"

#define RUN_FILE_NAME "runfile"
#define BUSY_FILE_NAME "busy"

// Check for file existance
int file_exists(char *filename) {

    struct stat buffer;
    return (stat (filename, &buffer) == 0);

int main (int argc, char* args[]) {

    if (argc != 4) {
        fprintf(stderr, "Wrong number of arguments\n");
        return -1;

    // Extract RGB values from the command line arguments
    int red   = atoi(args[1]);
    int green = atoi(args[2]);
    int blue  = atoi(args[3]);

    // Range check the specified color values
    if ((red   < 0) || (red   > 255) ||
        (green < 0) || (green > 255) ||
        (blue  < 0) || (blue  > 255)) {
        fprintf(stderr, "Color values in range 0 <= value < 256\n");
        return -1;

    // Create the busy file
    FILE *pFile = fopen (BUSY_FILE_NAME,"w");
    if (pFile != NULL) {
    }    else    {
        fprintf(stderr, "Could not create busy file\n");
        return -1;


    // Start SDL

    // Turn off cursor

    const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo();

    int width  = videoInfo->current_w;
    int height = videoInfo->current_h;
    uint8_t bpp = videoInfo->vfmt->BitsPerPixel;

    // Set up screen
    SDL_Surface *screen = SDL_SetVideoMode(width, height, bpp,
    if (!screen) {
        fprintf(stderr, "SDL_SetVideoMode failed\n");
        return -1;
    // Create the specified color
    uint32_t color = SDL_MapRGB(screen->format, red, green, blue);

    // Create rect the size of the screen
    SDL_Rect rect = {0, 0, width, height};

    // Fill the screen with the specified color
    SDL_FillRect(screen, &rect, color);

    // Update Screen

    // Pause

    // Wait until runfile is gone to terminate
    while (file_exists(RUN_FILE_NAME)) {

    // Delete the busy file
    if (remove(BUSY_FILE_NAME) != 0) {
        fprintf(stderr, "Error deleting busy file\n");

    // Quit SDL

    return 0;

Craig Lindley

If you're one in a million, there are now seven thousand people exactly
like you.

Re: Noob libssh questioncraig and heather <calhjh@xxxxxxxxx>
Re: Noob libssh questioncraig and heather <calhjh@xxxxxxxxx>
Re: Noob libssh questioncraig and heather <calhjh@xxxxxxxxx>
Re: Noob libssh questioncraig and heather <calhjh@xxxxxxxxx>
Re: Noob libssh questioncraig and heather <calhjh@xxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org