private void writeCommStatusAndClose(int status, String msg) {
   if (this.mCommFd != null) {
     if (status == MODE_WORLD_WRITEABLE) {
       Log.w(TAG, "Peer expected signal when closed; unable to deliver after detach");
     }
     if (status == -1) {
       IoUtils.closeQuietly(this.mCommFd);
       this.mCommFd = null;
       return;
     }
     try {
       this.mStatus = readCommStatus(this.mCommFd, getOrCreateStatusBuffer());
       if (this.mStatus != null) {
         IoUtils.closeQuietly(this.mCommFd);
         this.mCommFd = null;
         return;
       }
       byte[] buf = getOrCreateStatusBuffer();
       Memory.pokeInt(buf, 0, status, ByteOrder.BIG_ENDIAN);
       int writePtr = 0 + 4;
       if (msg != null) {
         byte[] rawMsg = msg.getBytes();
         int len = Math.min(rawMsg.length, buf.length - 4);
         System.arraycopy(rawMsg, 0, buf, writePtr, len);
         writePtr = len + 4;
       }
       Os.write(this.mCommFd, buf, 0, writePtr);
       IoUtils.closeQuietly(this.mCommFd);
       this.mCommFd = null;
     } catch (ErrnoException e) {
       Log.w(TAG, "Failed to report status: " + e);
     } catch (InterruptedIOException e2) {
       Log.w(TAG, "Failed to report status: " + e2);
     } catch (Throwable th) {
       IoUtils.closeQuietly(this.mCommFd);
       this.mCommFd = null;
     }
   } else if (msg != null) {
     Log.w(TAG, "Unable to inform peer: " + msg);
   }
 }