Australian workplace bullying case hinged on a Facebook unfriending

Australian real estate supervisor Lisa Bird was told by Australia’s Fair Work Commission that she “drew a line” in the workplace by unfriending one of her subordinates on Facebook. That meant the subordinate in question, real estate agent Rachael Roberts, no longer sees the friend version of the above Facebook profile. (credit: Facebook)

Earlier this week, the Australian Fair Work Commission ruled that a complaint about a real estate agent’s supervisor “bullying at work” should be upheld. While the list of complaints was lengthy, one of them, about being unfriended on Facebook, may make Australian coworkers think twice about how they interact online

read more

Australian workplace bullying case hinged on a Facebook unfriending

Australian real estate supervisor Lisa Bird was told by Australia’s Fair Work Commission that she “drew a line” in the workplace by unfriending one of her subordinates on Facebook. That meant the subordinate in question, real estate agent Rachael Roberts, no longer sees the friend version of the above Facebook profile. (credit: Facebook)

Earlier this week, the Australian Fair Work Commission ruled that a complaint about a real estate agent’s supervisor “bullying at work” should be upheld. While the list of complaints was lengthy, one of them, about being unfriended on Facebook, may make Australian coworkers think twice about how they interact online

read more

Difficulty with using fgets when reading strings through a pipe

I’m writing a program that consists of 2 processes. The parent reads data through stdin and then sends it to the child through a pipe. I’m using fgets() and fputs() to write and read the data.

The issue is that in certain situations the fgets() call of the child process seems to block. These are:

  1. When a text file is sent to stdin, everything works fine until the very last line of the file. The fgets of the child never executes and the process hangs.
  2. When I send /dev/urandom to the program the same situation occurs at a seemingly random moment.

I suspect the issue has something to do with EOF or /0 at the ends of these strings, but i can’t quite pinpoint the issue. Any help would be greatly appreciated.

I’m using the message queues as a means of synchronisation. I’m also aware there is no cleaning up in this code. Here it is:

#define KEY5 7626

struct pidbuf
{
    long mtype;
    int mtext;
} msgpid;

int main(){
    sleep(5);
    int mqpid;
    FILE * strumien;
    int fd[2];
    if (pipe(fd)== -1){
        perror("Create pipe error");
        exit(1);}

    int buf_len = 128;

    msgpid.mtext=0;
    int size1=sizeof(struct pidbuf)-sizeof(long);

    if((mqpid = msgget(KEY5, 0666 | IPC_CREAT))==-1){
        return(-1);
    }   
    char data[buf_len];

    if(fork()!=0){
        close(fd[0]);
        strumien=fdopen(fd[1],"w");
        while (fgets(data,buf_len,stdin) != NULL ) {
            printf("1:\n%s\n",data);
            fputs(data,strumien);
            fflush(strumien);
            msgpid.mtype=2;
            if(msgsnd(mqpid,&msgpid,size1,0)==-1){perror("msgsnd failed: 1");}

            msgrcv(mqpid,&msgpid,size1, 1, 0);
        }
        if(feof(stdin)!=0) printf("\nEnd of file\n");
    }
    else{   
        close(fd[1]);
        strumien=fdopen(fd[0],"r");
        msgrcv(mqpid,&msgpid,size1, 2, 0);
        while(fgets(data,buf_len,strumien)!=NULL){
            printf("2:\n%s\n\n",data);

            msgpid.mtype=1;
            if(msgsnd(mqpid,&msgpid,size1,0)==-1){perror("msgsnd failed: 1");}
            msgrcv(mqpid,&msgpid,size1, 2, 0); 
        }
    }
    return 0;
}

read more

Batch script help, script exiting after parentheses

I wrote a very simple script to output the host machine’s MAC addresses to a text file.

The script is exiting right after line 3 – ‘IF DEFINED WRITEOK (‘.

@echo off

cls

copy /Y NUL "%CD%\.writable" > NUL 2>&1 && set WRITEOK=1
IF DEFINED WRITEOK (
 rem ---- we have write access ----
 set DIR=%CD%\interfaces
 set FILE=%DIR%\%USERNAME%.txt
 IF NOT EXIST "%DIR%" (
  MKDIR "%DIR%"
  echo DIR '%DIR%' was created
 ) else (
  echo DIR '%DIR%' already exists
 ) for /f "tokens=2 delims=:" %%i in ('ipconfig /all ^| findstr /i "Physical Host"') do (
  echo %%i >> "%FILE%"
  echo OUTPUT written to '%FILE%'
 )

) else (
 rem ---- we don't ----
 echo DIR '%DIR%' is not writable
)

echo.
echo DONE!
pause

read more

Batch script help, script exiting after parentheses

I wrote a very simple script to output the host machine’s MAC addresses to a text file.

The script is exiting right after line 3 – ‘IF DEFINED WRITEOK (‘.

@echo off

cls

copy /Y NUL "%CD%\.writable" > NUL 2>&1 && set WRITEOK=1
IF DEFINED WRITEOK (
 rem ---- we have write access ----
 set DIR=%CD%\interfaces
 set FILE=%DIR%\%USERNAME%.txt
 IF NOT EXIST "%DIR%" (
  MKDIR "%DIR%"
  echo DIR '%DIR%' was created
 ) else (
  echo DIR '%DIR%' already exists
 ) for /f "tokens=2 delims=:" %%i in ('ipconfig /all ^| findstr /i "Physical Host"') do (
  echo %%i >> "%FILE%"
  echo OUTPUT written to '%FILE%'
 )

) else (
 rem ---- we don't ----
 echo DIR '%DIR%' is not writable
)

echo.
echo DONE!
pause

read more