Status writeStatus(final Status status, final File workingDirectory) throws IOException {
    FileOutputStream fileOut = null;
    ObjectOutputStream objectOut = null;

    try {
      fileOut = new FileOutputStream(new File(workingDirectory, statusFileName));
      objectOut = new ObjectOutputStream(fileOut);
      objectOut.writeObject(status);
      objectOut.flush();
      this.status = status;
      return this.status;
    } finally {
      IOUtils.close(objectOut);
      IOUtils.close(fileOut);
    }
  }
Sets the status of the GemFire JMX Agent by serializing a <code>Status</code> object to a
status file in the Agent's working directory.
<p>

@param status the Status object representing the state of the Agent process to persist to disk.
@return the written Status object.
@throws IOException if the Status could not be successfully persisted to disk.
geode-core/src/main/java/org/apache/geode/admin/jmx/internal/AgentLauncher.java